Friday, February 1, 2013

Re: [android-developers] Efficient way to update one of the childs of a ExpandableListView group?

Your Adapter has these getChildView and getGroupView methods. Both these methods have an argument called "convertView". That "convertView" argument is a view object that already has been created and filled with data by your adapter. If convertView is not null your Adapter should reuse that object instead of inflating or creating a new view.

And that's the whole point and one possible solution to your problem. You can "manually" do the same what ListAdapter does under the hood. Just get the correct child view you want to update and pass that child view as "convertView" argument to your adapter's getChildView method (with the correct group index and child item position of course). If your adapter is correctly programmed it will reuse that existing view object and just fill it with the correct data to display.

However, you may experience update errors while scrolling quickly through your listview. There are workarounds possible by using a scroll listener. When your listener detects a "fling" that causes fast scrolling, you could stop your updates, because they won't be visible anyway. You could also generally stop updates while the user is scrolling.

Now to the real question: why is scrolling your list view so slow? Even with using notifyDataSetChanged it shouldn't slow down that much because ListView only updates the currently visible list items and that's it.

What exactly does your adapter do in getChildView and getGroupView? Does it query a database? Does it decode bitmap objects? Does it read data from a file?
What does "getUpdateInfo" do?

You should create and update the adapter data only in a background thread. The UI thread should not be burdened with anything that might be blocking (like network or file I/O, database access, bitmap loading...). Is your handler code in your first post invoked on the UI thread? If so, you should move this update to a background thread that is continuously running and pausing for a second. When the activity is paused that thread should be stopped.

On Friday, February 1, 2013 1:37:05 PM UTC-6, saex wrote:
What? where should i put that view? i dont understand you...

the objective is to update one item instead of rebuilding the entire {expandable} list view.

So... what should i do with that view? how can i make that view to be refreshed when i want?

i'm stuck

El viernes, 1 de febrero de 2013 18:19:57 UTC+1, Kostya Vasilyev escribió:
And if you can't call getChildView, just copy the code from there to where you need it.

(Can't believe I wrote "copy the code"... will my developer license be revoked now?)

-- K

2013/2/1 skink <psk...@gmail.com>


saex wrote:
> argggggggggg you didn't understand me. I KNOW HOW TO GET THE VIEW, it is
> not the problem, read the full post please
>
>

i did read the full thread and still i think you should call
getChildView as Kostya suggested


pskink

--
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-d...@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups "Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups "Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment