Toast not generating text from selected item from list

后端 未结 5 2040
抹茶落季
抹茶落季 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:17

    I hope this way get selected item

          lv.setOnItemClickListener(new OnItemClickListener() {
    
                        public void onItemClick(AdapterView arg0, View arg1, int position,
                                long arg3) {
                            // TODO Auto-generated method stub
                         //  Toast.makeText(getApplicationContext(),"Position is: "+ position, Toast.LENGTH_LONG).show();
                           String selectedFromList = lv.getItemAtPosition(position).toString();
                            Toast.makeText(getApplicationContext(),selectedFromList , Toast.LENGTH_LONG).show();
                        }
                });
    

提交回复
热议问题