android - Select item in ListView crashes program -
i have listview allows me able select picture , working fine problem when select other pictures crushes , error message not understand , these pictures mysql database.
the content of adapter has changed listview did not receive notification. make sure content of adapter not modified background thread, ui thread. [in listview(16908298, class android.widget.listview) adapter(class car.store.carstore.mobilearrayadapter)]
thanx in advance.
myadapter looks this
public class mobilearrayadapter extends arrayadapter<string> { private final context context; private final string[] mycarlist = null; private arraylist<string> mycar = new arraylist<string>(); private arraylist<string> carimageurl = new arraylist<string>(); //arraylist<hashmap<string, string>> mycarlist = new arraylist<hashmap<string, string>>(); //arraylist<hashmap<string, string>> carimageurl = new arraylist<hashmap<string, string>>(); public mobilearrayadapter(context context,arraylist<string> bname,arraylist<string> burl) { super(context, r.layout.list_mobile, bname); this.context = context; this.mycar = bname; this.carimageurl = burl; } public view getview(int position, view convertview, viewgroup parent) { layoutinflater inflater = (layoutinflater) context .getsystemservice(context.layout_inflater_service); view rowview = inflater.inflate(r.layout.list_mobile, parent, false); textview textview = (textview) rowview.findviewbyid(r.id.label); imageview imageview = (imageview) rowview.findviewbyid(r.id.logo); textview.settext(mycar.get(position)); bitmap bitmap = null; // change icon based on name jsonobject json = jsonfunctions.getjsonfromurl("http://10.0.2.2/php/car.php"); // http://api.geonames.org/earthquakesjson?north=44.1&south=-9.9&east=-22.4&west=55.2&username=demo try{ jsonarray earthquakes = json.getjsonarray("cars"); //for(position=0;position<earthquakes.length();position++){ jsonobject e = earthquakes.getjsonobject(position); string bb = e.getstring("carname"); mycar.add(bb); string uu = e.getstring("carimage"); carimageurl.add(uu); //} }catch(jsonexception e){ log.e("log_tag", "error parsing data "+e.tostring()); } string s = mycar.get(position); string = carimageurl.get(position); system.out.println(s); system.out.println(i); try { bitmap = bitmapfactory.decodestream((inputstream)new url(i).getcontent()); } catch (malformedurlexception err) { // todo auto-generated catch block err.printstacktrace(); } catch (ioexception err) { // todo auto-generated catch block err.printstacktrace(); } //if (!s.equals("")) { imageview.setimagebitmap(bitmap); //} else { system.out.println("bitmap image: "+position+"="+bitmap); //imageview.setimageresource(r.drawable.android_logo); //} return rowview; }
try calling notifydatasetchanged() when add items list, requestlayout() may trick.
Comments
Post a Comment