Answer the question
In order to leave comments, you need to log in
How to call the setOnItemClickListener method?
I need to call a method setOnItemClickListener
which is relative to my listview, I tried to do it with listview.performItemClick()
, but it didn't work. Essentially my problem is that I just need to move to my next item in the listview, but I have a problem because my list is looped Integer.MAX_VALUE;
. How could I go to the next element in the list, or would it be better to call my setOnItemClickListener
?
Sources:
- Source class
- two questions on stackoverflow : 1 , 2
Answer the question
In order to leave comments, you need to log in
The previous answer was not entirely correct, I decided to correct it :)
/*В onCreate*/
listView.setOnItemClickListener(new DrawerItemClickListener());
/*После onCreate*/
private class DrawerItemClickListener implements ListView.OnItemClickListener {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
selectItem(position);
}
}
private void selectItem(int position) {
switch (position) {
case 0:
break;
case 1:
break;
default:
;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question