java - Use SimpleCursorAdapter with Image (path stored in SQLite) -


i have existing listview filled informations sqlite database. user can create profile of dog. after creating profiles list looks that:

example (sorry link need 10 rep direct picture)

as see there place pictures (dog images).

while creating profile user can add picture dog safed in internal storage /android/data/files/*.jpg (i don't want add sqlite database). name safed equals id of table row in sqlite database.

let's add new dog , id of row 134 the name of picture "134.jpg"

well atm have no idea how add picture listview.

any welcome!

last not least peace of code how fetch data sqlite:

private void filldata() {      mnotescursor = helper.fetchalldata();       string[] = new string[] { mydatabaseadapter.mysqlitehelper.name,             mydatabaseadapter.mysqlitehelper.password,             mysqlitehelper.cb_getreide, mysqlitehelper.cb_fastentag,             mysqlitehelper.cb_wochenplan, mysqlitehelper.cb_diet,             mysqlitehelper.sp_art  };       // fields on ui map     int[] = new int[] { r.id.label, r.id.gewicht,              r.id.getreide,             r.id.fastentag,              r.id.wochenplan,              r.id.diet,              r.id.spinner             };      adapter = new simplecursoradapter(getactivity(),             r.layout.hundeliste_item, mnotescursor, from, to, 0);      mmylistview.setadapter(adapter);  } 

if need more infos please ask, think important thing need more or less hint/idea how add pivture listview

edit: (because of merlevede's answers)

thanks @merlevede

i tryed following:

//... see post #1 upper code part  adapter = new simplecursoradapter(getactivity(),                 r.layout.hundeliste_item, mnotescursor, from, to, 0);            adapter.setviewbinder(new simplecursoradapter.viewbinder(){            // binds cursor column defined specified index specified view             public boolean setviewvalue(view view, cursor cursor, int columnindex){                 layoutinflater inflater = (layoutinflater) getactivity().getsystemservice(context.layout_inflater_service);                view = inflater.inflate(r.layout.hundeliste_item, null);                     if(view.getid() == r.id.imageview1){                     file mediastoragedir = new file(environment.getexternalstoragedirectory()                             + "/android/data/"                             + getactivity().getpackagename()                             + "/files");                      uri uri = uri.parse(mediastoragedir.getpath() + file.separator + item_id +".jpg");                      ((imageview)view.findviewbyid(r.id.imageview1)).setimagedrawable(drawable.createfrompath(uri.tostring())); return true; //true because data bound view                    }                     return false;               }             });     mmylistview.setadapter(adapter); 

but still don't show me pictures.

you use simplecursoradapter.viewbinder object bind imageview cursor.

look @ this link example. i'm copying example, should link ever become broken.

listadapter.setviewbinder(new simplecursoradapter.viewbinder(){    /** binds cursor column defined specified index specified view */    public boolean setviewvalue(view view, cursor cursor, int columnindex){        if(view.getid() == r.id.your_image_view_id){            //...            ((imageview)view).setimagedrawable(...);            return true; //true because data bound view        }        return false;    } });  

Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -