D
D
Dmitry Richter2014-12-28 23:10:02
Java
Dmitry Richter, 2014-12-28 23:10:02

How to call the setOnItemClickListener method?

I need to call a method setOnItemClickListenerwhich 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

1 answer(s)
A
Artix, 2015-01-03
@followthemoney

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 question

Ask a Question

731 491 924 answers to any question