Reputation: 520
In my Android Program I take a List of some application name like
1.Task Reminder 2.Profile
Now I want to click this list and want to enter into this application. I already write class for both of of the program. Can anyone please tell me how can I do this by using Intent?
Upvotes: 1
Views: 394
Reputation: 7110
Use this to add listeners to your listview
yourListViwObject.OnItemClickListener(this);
and when you use this your class will be prompted to implement OnItemClickListener .Do that and your class will ask you to add unimplemented methods .When you add them you will get a method onItemClick() and implement what you need to implement in this method like below
public void onItemClick(AdapterView arg0, View arg1, int arg2, long arg3) {
Toast.makeText(this,
"Item is clicked " + arg2,
600).show();
Intent i = new Intent(YourClass.this, TheActivityYouNeedToInvoke.class);
startActivity(i);
}
Upvotes: 2
Reputation: 21201
list.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView<?> arg0,
View arg1, int position, long arg3)
{
Intent n = new Intent(getApplicationContext(), profile.class);
// you can pass the value to profile class using "n.putExtra(name, value);"
startActivity(n);
}
});
Upvotes: 1