android - Pass intent extras which has been retrieved from a Hasmap based on onitemclick position -


hello guys want ask question android intent extras. new android enviroment.

i have programm displays records database listview. how can retrieve position of on itemclicklistener , inn way can pass name type , address other activity?

here code:

      public void updatejsondata() {       baravalaibleforuserlist = new arraylist<hashmap<string, string>>();       jsonparser jparser = new jsonparser();      jsonobject json = jparser.getjsonfromurl(show_bars_url);       try {           baravalaibleforuser = json.getjsonarray(tag_posts);           (int = 0; < baravalaibleforuser.length(); i++) {             jsonobject c = baravalaibleforuser.getjsonobject(i);              // gets content of each tag              string name = c.getstring(tag_name);             string address = c.getstring(tag_address);             string type = c.getstring(tag_type);             // creating new hashmap             hashmap<string, string> map = new hashmap<string, string>();              map.put(tag_name, name);             map.put(tag_address, address);             map.put(tag_type, type);               baravalaibleforuserlist.add(map);           }      } catch (jsonexception e) {         e.printstacktrace();     } }  private void updatelist() {       final listadapter adapter = new simpleadapter(this, baravalaibleforuserlist,             r.layout.layout_list_item, new string[] { tag_name, tag_address,             tag_type }, new int[] { r.id.bar_name_txt, r.id.bar_address_txt,             r.id.bar_type_txt });       setlistadapter(adapter);              listview  lv = getlistview();     lv.setonitemclicklistener(new onitemclicklistener() {          @override         public void onitemclick(adapterview<?> parent, view view,                                 int position, long id) {              intent intent = new intent(mainactivity.this,cafeinfo.class);                startactivity(intent);            }     }); } 

it starter question if has same question answer is:

 hashmap<string, string> map = baravalaibleforuserlist.get(position);              intent intent = new intent(mainactivity.this,cafeinfo.class);              intent.putextra("key",map.get(tag_name));             intent.putextra("key1",map.get(tag_address));             intent.putextra("key2",map.get(tag_type));             startactivity(intent); 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -