android - How can I access the second argument in the list? -


i'm wondering how can access second item in list? mean string outputs :

07-17 21:15:38.723: d/my app(15806): {feeling=joyful} 

but want read "joyful"

here code:

public class feelingsmain extends activity {

private static final string tag = "my app";  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main);      initlist();     listview lv = (listview) findviewbyid(r.id.pagelayout);     // design listview adapter     simpleadapter simpleadpt = new simpleadapter(this, feelingslist,             android.r.layout.simple_list_item_1,             new string[] { "feeling" }, new int[] { android.r.id.text1 });      lv.setadapter(simpleadpt);      lv.setonitemclicklistener(viewneeds);  }  list<map<string, string>> feelingslist = new arraylist<map<string, string>>();  private void initlist() {     // populate feelingslist     feelingslist.add(createfeeling("feeling", "wonderful"));     feelingslist.add(createfeeling("feeling", "content"));     feelingslist.add(createfeeling("feeling", "joyful"));     feelingslist.add(createfeeling("feeling", "tired"));     feelingslist.add(createfeeling("feeling", "gay"));     feelingslist.add(createfeeling("feeling", "sad"));     feelingslist.add(createfeeling("feeling", "amazing"));  }  private hashmap<string, string> createfeeling(string key, string name) {     hashmap<string, string> feeling = new hashmap<string, string>();     feeling.put(key, name);      return feeling;  }  onitemclicklistener viewneeds = new onitemclicklistener() {       @override     public void onitemclick(adapterview<?> arg0, view arg1, int arg2,             long arg3) {         // todo auto-generated method stub         // create variable database input         string feeling = feelingslist.get(arg2).tostring();         log.d(tag, feeling);          intent gotoneeds = new intent(feelingsmain.this, needs.class);         gotoneeds.putextra("afeeling", feeling);         startactivity(gotoneeds);     }  }; 

the string feeling equal feelingslist giving me problem. there method allows me access different parts of array, method seems return both elements.

look link: android - value hashmap

map<string, string> map = new hashmap<string, string>(); map.put("color1","red"); map.put("color2","blue"); map.put("color3","green"); map.put("color4","white");   system.out.println(map);  // {color4=white, color3=green, color1=red, color2=blue}            system.out.println(map.get("color2")); // blue   system.out.println(map.keyset());   // [color4, color3, color1, color2]  (map.entry<string,string> entry : map.entryset()) {    system.out.printf("%s -> %s%n", entry.getkey(), entry.getvalue()); } // color4 -> white 

// color3 -> green // color1 -> red // color2 -> blue

the credit @polygenelubricants 

Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -