I went trough a famous post in SO, Maintain/Save restore scroll position but does not help me at all.
I have a ListView inside a Fragment, if I change the orientation, I would like that saveInstance Bundle will save my position. I have
private static final String LIST_STATE = "listState";
private Parcelable mListState = null;
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
mListState = listView.onSaveInstanceState();
outState.putParcelable(LIST_STATE, mListState);
}
and does not matter if I put in OnCreateView or in onActivityCreated the following code
if(savedInstanceState!=null) {
mListState = savedInstanceState.getParcelable(LIST_STATE);
listView.onRestoreInstanceState(mListState);
the up position of the list is not restored at all. I can easily see from the debug in Bundle that the debug recognize in the Bundle the position,
AbsListView.SavedState{3d7562e0 selectedId=-9223372036854775808 firstId=25 viewTop=-38 position=5 height=717 filter=null checkState=null}
I even tried to extract from the Bundle this position in an isolated way instead of all the values, but without success.