android - Images in SimpleCursorAdapter -



android - Images in SimpleCursorAdapter -

i'm trying utilize simplecursoradapter viewbinder image database , set listview item view. here code:

private void setupviews() { mnewsview = (listview) findviewbyid(r.id.news_list); cursor cursor = getnews(); simplecursoradapter curadapter = new simplecursoradapter( getapplicationcontext(), r.layout.cursor_item, cursor, new string[] { "title", "content", "image" }, new int[] { r.id.cursor_title, r.id.cursor_content, r.id.news_image }); viewbinder viewbinder = new viewbinder() { public boolean setviewvalue(view view, cursor cursor, int columnindex) { imageview image = (imageview) view; byte[] bytearr = cursor.getblob(columnindex); image.setimagebitmap(bitmapfactory.decodebytearray(bytearr, 0, bytearr.length)); homecoming true; } }; imageview image = (imageview) findviewbyid(r.id.news_image); viewbinder.setviewvalue(image, cursor, cursor.getcolumnindex("image")); curadapter.setviewbinder(viewbinder); mnewsview.setadapter(curadapter); }

i getting :

android.database.cursorindexoutofboundsexception: index -1 requested, size of 60

while executing byte[] bytearr = cursor.getblob(columnindex);. have thought doing wrong?

i think cursor.movetofirst() has not been called cursor throwing android.database.cursorindexoutofboundsexception.

before using cursor should check cursor empty or not calling cursor.movetofirst(). position cursor @ first position.

android cursor blob indexoutofboundsexception android-viewbinder

Comments

Popular posts from this blog

java - How to pass parameters between Request-Scoped Controllers? -

actionscript 3 - Flex: moving a point with rotation doesnt change the point XY? -

string - what is the difference between "some" == "some\0" and strcmp("some","some\0") in c++? -