passing metadata from one activity to the next in an android listview -


i understand there's set of methods used pass data 1 activity next using, how model within activity list view?

example: have json object use populate listview. each list item has id. want pass id next activity on click. how know listview's item id? wasn't sure how attach arbitrary metadata listview item , grab , pass along.

public class stufflistactivity extends listactivity {     private myapplication application = null;      /**      * called when activity first created.      *      * @param savedinstancestate saved instance state      */     @override     public void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         application = ((application) getapplication());         requestor req = new requestor();         application.log(listtype.tostring());         arraylist<string> list = req.getstuff(application.getid(), listtype);          adapter = new arrayadapter<string>(this,                 r.layout.list, r.id.stuff, list);         setlistadapter(adapter);         }      protected void onlistitemclick(listview l, view v, int position, long id)      {         string item = (string) getlistadapter().getitem(position);         toast.maketext(this, item + " selected", toast.length_long).show();     } } 

use settag() , gettag() property list view in adapter getview() code.. store , retrieve data.


Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -