Got Data in json object from url but can't bind it to listview in android application -


i creating android application, in got data database per current longitude , latitude. got data in json object cant bind in listview. please guide me.

blockquote

**@override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.shopdetail);     aq=new aquery(this);         gpstracker  gps = new gpstracker(shopdetail.this);                    if(gps.cangetlocation()){                      double latitude = gps.getlatitude();                         double longitude = gps.getlongitude();                         getdatalatlog(latitude,longitude);                        }else{                         gps.showsettingsalert();                           }                     }** 

the getdatalatlog(latitude,longitude) method below.

blockquote

private void getdatalatlog(double latitude, double longitude) {      string link = "http://192.168.0.104/php/webservice/comments.php?latitude='"+latitude+"'&longitude='"+longitude+"'";     aq.progress(r.id.progressbar1).ajax(link, jsonobject.class, this,"jsoncallback"); } public void jsoncallback(string link, jsonobject json, ajaxstatus status) {                  mcommentlist = new arraylist<hashmap<string, string>>();     jsonparser jparser = new jsonparser();     json = jparser.getjsonfromurl(link);     try {         (success==1)         mcomments = json.getjsonarray(tag_posts);         (int = 0; < mcomments.length(); i++) {             jsonobject c = mcomments.getjsonobject(i);             string title = c.getstring(tag_title);             string content = c.getstring(tag_message);             string username = c.getstring(tag_username);             hashmap<string, string> map = new hashmap<string, string>();             map.put(tag_title, title);             map.put(tag_message, content);             map.put(tag_username, username);             mcommentlist.add(map);         }     } catch (jsonexception e) {         e.printstacktrace();     } listadapter adapter = new simpleadapter(this, mcommentlist,             r.layout.single_post, new string[] { tag_title,tag_username ,tag_message                     }, new int[] { r.id.shop_name,r.id.address,r.id.distance                      });     setlistadapter(adapter);     listview lv = getlistview();         lv.setonitemclicklistener(new onitemclicklistener() {         @override         public void onitemclick(adapterview<?> parent, view view,                 int position, long id) {         }     }); }* 

please may :

listadapter adapter = new simpleadapter(this, mcommentlist,                 r.layout.single_post, new string[] { tag_title,tag_username ,tag_message                         }, new string[] { getresources().getstring(r.id.shop_name),getresources().getstring(r.id.address),getresources().getstring(r.id.distance)                          }); 

here changed integer type array string because did shows integer value or blank value.but want use resource android have mention resource() method.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -