Only relay children and not the whole tree

I am trying to recreate the logic of ListView (and AbsListView ) with a view redesign. I need this, but we can only say this to understand the logic of Android.

Suppose my children are the same (same layout) using a fixed height RelativeLayout .

While scrolling, I reuse the ghost children view and set the properties for the current item. It works fine as I use View.offsetTopAndBottom() and invalidate() instead of requesting the layout while scrolling for optimization.

My problem is updating child elements ( RelativeLayout ).

Depends on the element, I want to hide or show the ImageView in this element. For this, I just use iconImage.setVisibility( GONE ) and iconImage.setVisibility( VISIBLE ) .

Since I am blocking requestLayout , it seems that setVisibility() is not working correctly.

If I use requestLayout , the whole tree will be measured by the layout itself, and this is not a good way to scroll through the user experience.

Is there a way to query layout only for the recycle child?

+8
android layout
source share
1 answer

You need to notify your listView with the changed view, so call notifyDataSetChanged(); from Uithread as follows:

  final ArrayAdapter adapter = ((ArrayAdapter) getListAdapter()); runOnUiThread(new Runnable() { @Override public void run() { adapter.notifyDataSetChanged(); } }); 
-2
source share

All Articles