Circular / carousel like listview "setSelection"

I have a listview and I gave an effect circular/carousel

to this list by specifying setSelection(SomeHighValueNumber)

. And now I need the actual functionality setSelection(position)

to navigate to a specific position. Since I've already used setSelection

to get a circular effect, how can I achieve this?

For instance

In the adapter class I did the following

        @Override
        public int getCount() {
            return Integer.MAX_VALUE;
        }

        @Override
        public Object getItem(int position) {
            return list.get(position%mListAdapterCount);
        }

      

Then

LvR = (TwoWayView)mainLayoutR.findViewById(R.id.listViewR);
LvR.setAdapter(applicationsAdapter);
LvR.setSelection(500);

      

Now tell me that I want to move to 6th position in the LvR list. I cannot use setSelection again as it removes the carousel effect from my LvR view list.

+3


source to share


1 answer


Finally I found a solution myself. Here you go

For instance

int selection = 500;



LvR.setSelection (selection);

And if you want to go to X position in ListView LvR. Use this

LvR.setSelection (selection + X);

0


source







All Articles