Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - how to update ListView item that is currently displayed

I have list of items in my activity which I load dynamically, item after item. Initially I load "lightweight" version and when processing is done I want to update the item with new information. Like set some text or replace an image. That means I need to update what ListView item is displaying after Adapter#getView already returns. Of course I don't know if user is actively scrolling and this item is still visible or has been scrolled out ot view. The only thing I can think of is to extend View so it performs some operations on it's own thread and updates itself when done,but will it work? Thanks for your suggestions

like image 876
Bostone Avatar asked Nov 25 '25 16:11

Bostone


2 Answers

This android-developers example may be helpful: http://android-developers.blogspot.com/2010/07/multithreading-for-performance.html

like image 52
QRohlf Avatar answered Nov 28 '25 03:11

QRohlf


code is:

dataAdapter.remove(dataAdapter.getItem(clickedpos));     
dataAdapter.insert(t.getText().toString(), clickedpos);

delete previous item on that position and add new item to that position

like image 26
greeshma Avatar answered Nov 28 '25 04:11

greeshma



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!