tags:

views:

235

answers:

2

Hi,

I have a ListView in my android activity. And I populate the ListView by sub-class the BaseAdaptor (which returns a View in getView() method).

What if in my click listener of a button in a list item view, I

  • change the text of the TextView in the List item view or
  • change the dimension of the list item view by adding/removing children of the list item view

What is an efficient to refresh my listView? I don't want the listView to re-trigger a query since there is no data change.

Thank you.

A: 

Hi,

if you just change the content of your Children View, you have not more to do than TextView.setText(newText).

If you change the count of your ListView childrens, you have to call BaseAdaptor.notifyDataSetChanged()

3dmg
I dont' change the count of the ListView. I just change number of children of the ViewGroup in 1 of the ListView Item.
michael
A: 

I was about to suggest that you invalidate(), but you don't want to trigger a redraw, so I can only suggest that some form of global flag is your best bet. Set the flag, invalidate or redraw and query (and reset) the flag in OnDraw()

Mawg
I just don't want to trigger a requery. But when you said invalidate(), you talked about invalidate() the ListView() or the view of the list item? Moreover, I can't call invalidate() in my OnClickListener(). Isn't android guard against updating the UI in a non-UI thread?
michael