Fix ListView losing scroll position
Restrict restoring the selected position when AdapterView gets restored for Spinner instances only. Bug: 26991402 Bug: 23619366 Change-Id: Ib002eac5ed0b8810a3e9988ad36f03450cb03b9b
This commit is contained in:
@@ -356,10 +356,18 @@ public abstract class AbsSpinner extends AdapterView<SpinnerAdapter> {
|
||||
return mFirstPosition + i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return INVALID_POSITION;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void dispatchRestoreInstanceState(SparseArray<Parcelable> container) {
|
||||
super.dispatchRestoreInstanceState(container);
|
||||
// Restores the selected position when Spinner gets restored,
|
||||
// rather than wait until the next measure/layout pass to do it.
|
||||
handleDataChanged();
|
||||
}
|
||||
|
||||
static class SavedState extends BaseSavedState {
|
||||
long selectedId;
|
||||
int position;
|
||||
|
||||
@@ -815,7 +815,6 @@ public abstract class AdapterView<T extends Adapter> extends ViewGroup {
|
||||
@Override
|
||||
protected void dispatchRestoreInstanceState(SparseArray<Parcelable> container) {
|
||||
dispatchThawSelfOnly(container);
|
||||
handleDataChanged();
|
||||
}
|
||||
|
||||
class AdapterDataSetObserver extends DataSetObserver {
|
||||
|
||||
Reference in New Issue
Block a user