0
For now my code is like this ? how do I implement the click of the list items the click would open a new screen
ListView lista_teste = (ListView)findViewById(R.id.lista_teste);
String[] dados = new String[]{"xxxxx","xxxx"};
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, dados){
@Override
public View getView(int position, View convertView, ViewGroup parent){
// Get the Item from ListView
View view = super.getView(position, convertView, parent);
// Initialize a TextView for ListView each Item
TextView tv = (TextView) view.findViewById(android.R.id.text1);
// Set the text color of TextView (ListView Item)
tv.setTextColor(Color.WHITE);
// Generate ListView Item using TextView
return view;
}
};
lista_teste.setAdapter(adapter);
in this example any item I click will do that is not?
– João Vitor
Yes. I forgot to put a command. After executing startActivity it is necessary to destroy the current screen with the command Finish();
– Felipe Santos
da para separa por posição tbm tipo se item position 1 selected Open Screen 1 If position 2 selected Screen 2? I searched and did not find, in case this would be my need
– João Vitor
yes, within the onItemClick method, it brings the position parameter, which is the element that was clicked. You can do, if position = 1 opens screen 1, if position = 2 opens screen 2 and so on.
– Felipe Santos
vlw in thank you very much
– João Vitor