Setting New Pages Linked By An Activity
In the application I am writing, I have a main class which extends the ListActivity - it contains a list of elements. I want these elements to link to a different page (an xml one,
Solution 1:
Looks like you are trying to launch a new activity.
You have to override the onListItemClick
method of ListActivity
.
Here is the code.
// ListView l points to list view whose item user clicked// View v points to the item in the list view on which the user clicked// int position is the position index of the item in the list// long id is the id assigned to the item. This id is assigned using the ListAdapter, CursorAdapter etc.@OverrideprotectedvoidonListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
// I am using getApplicationContext() as it is more safe then just passing `this`Intenti=newIntent(this.getApplicationContext(), ActivityToRun.class);
this.startActivity(i);
}
NOTE: You have to improve on this skeleton depending upon your needs.
Solution 2:
Have you tried setting the XML page as a ListView
and give it the ID @android:id/list
?
Post a Comment for "Setting New Pages Linked By An Activity"