android - Send Json data from listview in one activity to another activity -
i trying send json object data 1 activity other activity. have listview populated json array, click on list item, not responding. no action being performed on item click. saw tutorials did not helped. need send list item's json data activity. appreciated.
activity of listview populated json.
try{ jarray = new jsonarray(result); listview listview=(listview)findviewbyid(r.id.listtour_cat); listview.setadapter(new listviewadapter(jsonuseactivity.this,jarray)); listview.setonitemclicklistener(new onitemclicklistener() { @override public void onitemclick(adapterview<?> arg0, view arg1, int arg2, long arg3) { // todo auto-generated method stub try{ if(!jarray.isnull(arg2)){ intent intent = new intent(getapplicationcontext(),tourdetailactivity.class); intent.putextra("id", jarray.optjsonobject(arg2).getstring("tour_id")); startactivity(intent); } } catch(jsonexception e){ log.e("log_tag", "error parsing data "+e.tostring()); } } }); } catch(jsonexception e){ log.e("log_tag", "error parsing data "+e.tostring()); } } catch (exception e) { log.e("log_tag","error in http connection!!" + e.tostring()); }
target activity:
intent intent = getintent(); string rcvid = intent.getstringextra("id"); toast.maketext(getapplicationcontext(), rcvid, toast.length_long).show();
convert jsonarray string attach intent ans send it.
jsonobject jobject = new jsonobject("your json response"); intent obj_intent = new intent(main.this, main1.class); bundle b = new bundle(); b.putstring("array",jobject4.tostring()); obj_intent.putextras(b);
where jobject4 json object.
get in next page :
intent b = getintent().getextras(); string array=b.getstring("array");
Comments
Post a Comment