Restore ListView Previous State in Android

// save index and top position
int index = mylistview.getFirstVisiblePosition();
View v = mylistview.getChildAt(0);
int top = (v == null) ? 0 : v.getTop();
// restore
mylistview.setSelectionFromTop(index, top);


// Save ListView state
Parcelable state = listView.onSaveInstanceState();

// Set new items

// Restore previous state (including selected item index and scroll position)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: