How to extract the text from the selected item on the listView

后端 未结 14 2550
轻奢々
轻奢々 2020-11-28 07:55

I have a listview with some items. I would like to get the text from the selected item.

Here is my list adapter and the onItemClickListener:

ListView         


        
14条回答
  •  旧巷少年郎
    2020-11-28 08:30

    It is as simple as that

    @Override
            public void onItemClick(AdapterView adapterView, View view, int i, long l) {
                TextView text1 = (TextView) findViewById(R.id.Text1);
                TextView text2 = (TextView) findViewById(R.id.Text2);
    
                String txt_1 = ""+text1.getText().toString().trim();
                String txt_2 = ""+text2.getText().toString().trim();
    
               //Other_Related_Work
    
            }
        });
    

提交回复
热议问题