android - Values from the Intent is not showing -
i don't know did wrong on here. have followed tutorial values end being empty.
passsing values intent
listview lvitems = (listview) view.findviewbyid(r.id.lvdashboardcompleted); lvitems.setonitemclicklistener(new adapterview.onitemclicklistener() { @override public void onitemclick(adapterview<?> parent, view view, int position, long id) { //toast shows id on here intent intent = new intent(getactivity(), categoryactivity.class); intent.putextra("category_id", id); startactivity(intent); } });
reviving value intent
public class categoryactivity extends appcompatactivity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); getsupportactionbar().hide(); setcontentview(r.layout.activity_category); string recevied_cat_id = getintent().getstringextra("category_id"); context context = getapplicationcontext(); charsequence text = recevied_cat_id; int duration = toast.length_short; toast toast = toast.maketext(context, text, duration); toast.show(); } }
try replace oncreate
method. issue? @arif has highlighted correctly, passing long intent in method retrieving string.
protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); getsupportactionbar().hide(); setcontentview(r.layout.activity_category); long recevied_cat_id = getintent().getlongextra("category_id", 1l); context context = getapplicationcontext(); string strlong = long.tostring(recevied_cat_id); charsequence text = strlong; int duration = toast.length_short; toast toast = toast.maketext(context, text, duration); toast.show(); }
Comments
Post a Comment