Possible Duplicate:
Android - ListView click HOWTO?
to be more specific I have a list of Restaurants in a list view and I want to click on a restaurant in the list then be directed to another list that has the menu for that resturan thanks
Possible Duplicate:
Android - ListView click HOWTO?
to be more specific I have a list of Restaurants in a list view and I want to click on a restaurant in the list then be directed to another list that has the menu for that resturan thanks
Wire up the onItemClickListener
on the list object.
Try this:
listView = (ListView) findViewById(R.id.my_list_view);
listView.setAdapter(someAdapter);
listView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
switch(position) {
case 0:
Intent intent = new Intent();
intent.setClassName("com.test", "com.test.SubMenuActivity");
startActivity(intent);
break;
case 1:
// Do something else ...
break;
// ...
}
});