Improve Preference highlighting

- add PreferenceFragment.onBindPreferences() so that we can know
when the binding as been done
- use the Preference's key as a tag for its View (so that we can
locate it latter in the View hierarchy)

Change-Id: Ifb3b30e576048b7464af63643834d278a46a8543
This commit is contained in:
Fabrice Di Meglio
2014-04-17 17:14:59 -07:00
parent 35d7b89b9f
commit 8a86d734e5
2 changed files with 6 additions and 1 deletions

View File

@@ -329,6 +329,11 @@ public abstract class PreferenceFragment extends Fragment implements
if (preferenceScreen != null) {
preferenceScreen.bind(getListView());
}
onBindPreferences();
}
/** @hide */
protected void onBindPreferences() {
}
/** @hide */

View File

@@ -20,7 +20,6 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.preference.Preference.OnPreferenceChangeInternalListener;
@@ -243,6 +242,7 @@ public class PreferenceGroupAdapter extends BaseAdapter
if (position == mHighlightedPosition && mHighlightedDrawable != null) {
result.setBackgroundDrawable(mHighlightedDrawable);
}
result.setTag(preference.getKey());
return result;
}