android - Change background color of ListView item after 3 seconds -



android - Change background color of ListView item after 3 seconds -

i have list of items "seen" or "not seen" in arraylist<item>. if they're not seen alter background color of listview item in customarrayadapter :

if(item.is_seen == null || item.is_seen == 0) { row.setbackgroundresource(r.color.yellow); } else { row.setbackgroundresource(r.color.transparent); }

now want set items background transparent after 3 seconds spent on page.

i tried this:

mscheduledexecutor.schedule(new runnable() { @override public void run() { for(int i=0; i<mitems.size(); i++) { final item n = mitems.get(i); if(n.is_seen == null || n.is_seen == 0) { // update value in db int isseen = 1; updateitem(n._id, isseen); // alter color of backgrounds view view = listviewitem.getchildat(i); if(view != null) { view.setbackgroundresource(r.color.red); } } }

updating value in db works, rest doesn't. i'd avoid reload data. need color change.

i don't have errors, nothing.

i everywhere reply , didn't find one. wrong since beginning? want accomplish possible?

i give thanks in advance help give me.

instead of changing color of view youre doing,

// alter color of backgrounds view view = listviewitem.getchildat(i); if(view != null) { view.setbackgroundresource(r.color.red); }

(code above not work, because views recycled in listadapter) update info off build list - add together property class passing listadapter, grab instance list , update property, have position @ needs updated already, that's easy. then, phone call notifydatasetchanged() on list. not redraw list if didn't add/remove items list, update right view you. way - absolutely no way view corresponding specific element in list after list has been drawn already. way refresh/redraw list notifydatasetchanged(), followed refreshdrawablestate().

android listview

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -