android - passing values between activities -


hello have following code retreving data server , when click on item show me id retrieve server . instead of showing in toast want pass activity. here orginal code

public class test extends listactivity  {       prefs myprefs = null;      @override     public void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.listplaceholder);         this.myprefs = new prefs(getapplicationcontext());         // install handler processing gui update messages         arraylist<hashmap<string, string>> mylist = new arraylist<hashmap<string, string>>();        jsonobject json = jsonfunctions.getjsonfromurl("http://midsweden.gofreeserve.com/proj/androidjson.php?identifier=" +          test.this.myprefs.getpersonalno());          try{              jsonarray  earthquakes = json.getjsonarray("services");              for(int i=0;i<earthquakes.length();i++){                                         hashmap<string, string> map = new hashmap<string, string>();                     jsonobject e = earthquakes.getjsonobject(i);                  map.put("id",  string.valueof(i));                 map.put("pic", "service name : " + e.getstring("employeepic"));                 map.put("serviceinfo", "" +  e.getstring("employeename")+ " : "+ e.getstring("starttime")                         +" " +  e.getstring("endtime"));                 mylist.add(map);                         }                }catch(jsonexception e)        {              log.e("log_tag", "error parsing data "+e.tostring());         }          listadapter adapter = new simpleadapter(this, mylist , r.layout.test,                          new string[] { "servicename", "serviceinfo" },                          new int[] { r.id.item_title, r.id.item_subtitle });          setlistadapter(adapter);          final listview lv = getlistview();         lv.settextfilterenabled(true);           lv.setonitemclicklistener(new onitemclicklistener() {             public void onitemclick(adapterview<?> parent, view view, int position, long id) {                               @suppresswarnings("unchecked")                 hashmap<string, string> o = (hashmap<string, string>) lv.getitematposition(position);                                    toast.maketext(test.this, "id '" + o.get("id") + "' clicked.", toast.length_short).show();               }         });      } 

i trying adjust code every time "force close"

intent intent = new intent(test.this, passing.class); intent.putextra("employename", employeename); startactivity(intent); 

for id done in following way . how can replace employename

lv.setonitemclicklistener(new onitemclicklistener() {         public void onitemclick(adapterview<?> parent, view view, int position, long id) {                           @suppresswarnings("unchecked")                 hashmap<string, string> o = (hashmap<string, string>) lv.getitematposition(position);                                intent intent = new intent(test.this, passing.class);             intent.putextra("id", id);             startactivity(intent);               }         });  } 

hi umar have couple of questions you... have tried inserting starting new activity part in place have toast statement. if , after inserting force close dialog comes.. please check whether have class name passing , defined activity in manifest... if still getting force close anr post logcat solve problem..


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -