how to pass an item from a listview to a textview in the same Activity

0

My question is about capturing information in a ListView on Android and pasting the same information into a TextView .

Example: I created a ListView of fruits and I want you to click on a fruit from the list the name of this fruit will appear in this TextView .

    
asked by anonymous 30.11.2018 / 18:49

1 answer

0

Try this:

seuListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { itemSelecionado = lista.get(i); seuTextView.setText(itemSelecionado); return false; } });

This "list" is the list that is populating your ListView (List, ArrayList, etc.)

I hope I have helped

    
07.12.2018 / 19:39