0

I set my adapter to my list

ListView listView = (ListView)  view.findViewById(R.id.listViewMovies);
listView.setAdapter(myAdapter);

Now how can I set the initial scroll position of my list?

edit

smoothScrollToPosition does not work

ListView listView = (ListView)  view.findViewById(R.id.listViewMovies);
listView.setAdapter(myAdapter);
listView.smoothScrollToPosition(123);

setSelection does not work

ListView listView = (ListView)  view.findViewById(R.id.listViewMovies);
listView.setAdapter(myAdapter);
listView.setSelection(123);
the_prole
  • 8,275
  • 16
  • 78
  • 163

2 Answers2

1

You may use listview.smoothScrollToPosition() function. refer this : Programmatically scroll to a specific position in an Android ListView

Community
  • 1
  • 1
0

calling

listview.post(new Runnable() {

    @Override
    public void run() {
        listview.setSelection(mSelectedPosition);
    }
});

seems to have helped others.

Matthew Shearer
  • 2,715
  • 3
  • 23
  • 32