0
I have an Activity with a button calling a List Activity. This Listactivity quickly creates a string list, I just want to show this list on the screen and display the selected item in a Toast.
But it’s not working! Follow the code of the List class
public class Lista extends ListActivity{
protected void OnCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
String[] itens = new String[]{"João","josé","pedro",};
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,itens);
setListAdapter(adapter);
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
Object o = this.getListAdapter().getItem(position);
String item = o.toString();
Toast.makeText(this, "Clicou em: "+item, Toast.LENGTH_SHORT).show();
}
}
What is missing?
What is the error shown in the console? Is the method even called? (put the debug or a sysout to check) If a better description of the scenario becomes difficult to help
– Felipe Fonseca