android - Why my ViewBinder shows the last element wrong? -
i have big problem , tried debug long time can not error.
i have listview , load pictures, path saved in database.
its works fine, have 1 problem: if have e.g. 4 items. first 2 have pictures , last 2 not. last item in list have picture last item had picture , can not figure out why. looked in database if maybe have path in last element empty.
there code:
simplecursoradapter adapter; adapter = new simplecursoradapter(this, r.layout.my_listlayout, maincontroller.getinstance().getmycursor(db), new string[] {"f1", "f2", "f3", "f4"}, new int[] {r.id.imageviewf1, r.id.textviewf2, r.id.textviewf3, r.id.textviewf4}, 0); adapter.setviewbinder(new viewbinder() { public boolean setviewvalue(view view, cursor cursor, int columnindex) { if (columnindex == 1) { imageview imageview = (imageview) view; string pic = cursor.getstring(1); if (pic != null) { // load picture in view imageview.setimagedrawable(...); } return true; } if (columnindex == 2) { //.. } if (columnindex == 3) { //.. } if (columnindex == 4) { //.. } return false; } }); listview view = (listview)findviewbyid(r.id.listviewfirst); view.setadapter(adapter);
maybe i'm doing wrong in adapter?
Comments
Post a Comment