android - ImageView setBackgroundRessource not update even with inflate -


i'm trying update imageview gridview border, doing have xml file works :

<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android">     <item>          <shape android:shape="rectangle">             <solid android:color="#158cdb" />          </shape>     </item>        <item android:left="3dp" android:right="3dp" android:top="3dp" android:bottom="3dp">           <shape android:shape="rectangle">              <solid android:color="#ffffff" />         </shape>     </item>     </layer-list>  

so launch activity, timer launched , after 15 secondes, try update imageview, tried code :

public void highlightfooditem(int id) {     imageadapter ia = (imageadapter) _grid.getadapter();     (int = 0; < ia.getcount(); i++) {         view currentview = ia.getview(i, null, _grid);         if(id == integer.valueof(currentview.gettag().tostring().trim())) {             currentview.setbackgroundresource(r.drawable.border);             currentview.invalidate();         }        } } 

so grid of course gridview i'm using, checked enter in if nothing happend , don't see why... it's right view, have position.

if need timer launch function :

public void timer(int duration, int tick) {     _timer = new countdowntimer(duration, tick) {          public void ontick(long millisuntilfinished) {             _isrunning = true;         }          public void onfinish() {             _isrunning = false;             string currentmeal = getmealtype();             int currentcounter = -1;             int currentfooditemid = -1;              (int = 0; < _user.get_preferences().size(); i++) {                 historic temp = _user.get_preferences().get(i);                 string[] hmealtype = temp.gettype().split("_");                   if(currentmeal.equals(hmealtype[1]) && hmealtype[0].equals("preferences")) {                     if(temp.getcounter() > currentcounter && !_foodlist.selectlistcontainsfood(temp.getfooditemid())) {                         currentfooditemid = temp.getfooditemid();                         currentcounter = temp.getcounter();                     }                 }             }              _prompt.settext("> maybe should take a(n) "+_foodlist.getfooditemname(currentfooditemid)+" it.");              final int id = currentfooditemid;             runonuithread(new runnable() {                 @override                 public void run() {                     highlightfooditem(id);                                       }             });         }     };     _timer.start(); } 

if can me...

best regards, zed13

ps : forgive poor english x)

ok, try update view got image adapter, if use function getchildat gridview succeed function :

public void highlightfooditem(int id) {     imageadapter ia = (imageadapter) _grid.getadapter();     (int = 0; < ia.getcount(); i++) {         view currentview = ia.getview(i, null, _grid);         if(id == integer.valueof(currentview.gettag().tostring().trim())) {             _grid.getchildat(i).setbackgroundresource(r.drawable.border_cyan);                   }        } } 

Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -