I want to develop an android application using listView, what I want to do is when I press on an Item on the list it will take me to another activity and so on, how can I do that
Asked
Active
Viewed 688 times
0
-
What did you already try? Did you try google? – L.Butz Nov 02 '13 at 18:49
-
@L.Butz I tried google it, but all the examples I saw just display a toast not taking me to another activity – ruaa.brkat Nov 02 '13 at 18:50
-
1You could use this example instead of displaying a toast: http://stackoverflow.com/questions/4186021/how-to-start-new-activity-on-button-click – L.Butz Nov 02 '13 at 18:53
-
@L.Butz I know how to do that but I don't know how to do that using ListView – ruaa.brkat Nov 02 '13 at 19:00
2 Answers
1
I want to develop an android application using listView
I guess you should try using Eclipse ADT to develop apps :D
What you are looking for is an OnItemClickListener
. Usage:
yourListView.setOnItemClickListener(new OnItemClickListener()
{
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
{
startActivity(new Intent(CurrentActivity.this, yourNextActivity.class));
}
});

Droidman
- 11,485
- 17
- 93
- 141
0
there are many samples for this. To summarize it will be something like this:
yourListView.setOnItemClickListener(new OnItemClickListener(){
public void onItemClick(AdapterView<?> parent, View view, int position, long id){
Intent intent = new Intent(<YourCurrentActivity>.this, <YourNextActivityToStart>.class);
startActivity(intent);
}
});

Devrim
- 15,345
- 4
- 66
- 74