Fix b/265617603: The 'breakdown by systems' list will change to 'breakdown by apps' after the user scrolls up and down.
The root cause is that the spinner was initialized many times for every onBindViewHolder(). When the spinner is scrolled out of the screen and scrolled back, onBindViewHolder() is triggered. The spinner selection position was set to the mSavedSpinnerPosition. This is unexpected. Only the first initialization should set the saved position. This fix changes the spinner initialization to be only once. Bug: 265617603 Fix: 265617603 Test: manual Change-Id: I7ebd2b074cf6f560919ceec338eb8fcfaadf4d3a
This commit is contained in:
@@ -56,6 +56,10 @@ public class SpinnerPreference extends Preference {
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(PreferenceViewHolder view) {
|
||||
if (mSpinner != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
mSpinner = (Spinner) view.findViewById(R.id.spinner);
|
||||
mSpinner.setAdapter(new SpinnerAdapter(getContext(), mItems));
|
||||
mSpinner.setSelection(mSavedSpinnerPosition);
|
||||
|
Reference in New Issue
Block a user