I know that ListActivity
gives me the possibility to use onListItemClick
.
On the other hand in a normal Activity
i can include multiple lists and make easy switching+animation through a ViewFlipper
.
So. Can i make it work alltogether?
[Solved] Yes! ... implements are the kings. Deleted my code to minimize confusion开发者_运维百科.
Have you tried having your Activity implement OnItemClickListener and then set your lists' onItemClickListener to the activity? I.e.
public class MyActivity extends Activity implements OnItemClickListener {
...
public void onCreate(...) {
...
mList1.setOnItemClickListener(this);
mList2.setOnItemClickListener(this);
...
}
...
public void onItemClick(AdapterView<?> adapter, View view, int position, long id) {
if (adapter.getId() == R.id.list1) {
// Handle list1 click event
} else if (adapter.getId() == R.id.list2) {
// Handle list2 click event
}
}
}
精彩评论