Toast not generating text from selected item from list

后端 未结 5 2046
抹茶落季
抹茶落季 2021-01-25 17:42

I\'ve made a simple app in android with list View,In that i want to make a toast when select an item,i have tried as below but its not working..

my code is as below:

5条回答
  •  执念已碎
    2021-01-25 18:22

    HashMap selectedValue = (HashMap) (lv.getItemAtPosition(position));         
    ArrayList list = new ArrayList(selectedValue.keySet());             
    Toast.makeText(getApplicationContext(), selectedValue.get("txt"), Toast.LENGTH_LONG).show();
    

    That hashmap has got keys which are present in that list. That list is actually the from array which you have given. Just give the corresponding key to display the corresponding text.

    Its working. :)

提交回复
热议问题