-5

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

Community
  • 1
  • 1

2 Answers2

1

Wire up the onItemClickListener on the list object.

cjk
  • 45,739
  • 9
  • 81
  • 112
1

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;
            // ... 
        }
    });     
Ali Behzadian Nejad
  • 8,804
  • 8
  • 56
  • 106