Tuesday, 15 March 2011

web services - How to bind String[] values in listview using hashmap in android? -



web services - How to bind String[] values in listview using hashmap in android? -

hi trying values using hashmap<> using .net web services in android. have custemized adapter, trying this.

soapobject folderresponse = (soapobject)envelope.getresponse(); log.i("allfolders", folderresponse.tostring()); string[] folderslist = new string[folderresponse.getpropertycount()]; //getting values using folderslist. arraylist<hashmap<string, string>> hashfolderslist = new arraylist <hashmap<string, string> >(); //but want hashfolderslist list in custamized adapter. for(i=0; i<folderresponse.getpropertycount(); i++) { soapobject singlefolder = (soapobject)folderresponse.getproperty(i); log.i("singlefolder", singlefolder.tostring()); id= singlefolder.getproperty(0).tostring(); key_name = singlefolder.getproperty(1).tostring(); parentid = singlefolder.getproperty(2).tostring(); createdby= singlefolder.getproperty(3).tostring(); system.out.println(id); system.out.println(key_name); system.out.println(parentid); system.out.println(createdby); soapprimitive record =(soapprimitive) singlefolder.getproperty(1); log.i("record", record.tostring()); { folderslist[i] = singlefolder.getproperty(0).tostring(); } xmlparser parser = new xmlparser(); string xml = parser.getxmlfromurl(url); // getting xml url org.w3c.dom.document doc = parser.getdomelement(xml); // getting dom element nodelist nl = (nodelist) doc.getelementsbytagname(id); // looping through song nodes <song> (int = 0; < nl.getlength(); i++) { // creating new hashmap hashmap<string, string> map = new hashmap<string, string>(); element e = (element) nl.item(i); // adding each kid node hashmap key => value map.put(id, parser.getvalue(e, id)); map.put(key_name, parser.getvalue(e, key_name)); map.put(parentid, parser.getvalue(e, parentid)); map.put(createdby, parser.getvalue(e, createdby)); folderslist.add(map); } listview = (listview)findviewbyid(r.id.listview); adapter=new lazyadapter(this, hashfolderslist); //my custemized adapter. listview.setadapter(adapter); listview.setonitemclicklistener(this); } }

please suggest, how values in list using arraylist> hashfolderlist, using string[] folderlist. when inserting hashfolderlist, giving error. please suggest. thanks

mate should have simple adapter take strings , set within listview. sec should have 2 textviews

simpleadapter adapter = new simpleadapter(this, list, r.layout.your_activity, new string[] { "", "" }, new int[] { r.id.textview1, r.id.textview2 } ); listview1.setadapter(adapter);

hope helps you!!

string web-services android-listview baseadapter

No comments:

Post a Comment