I need to create a settings screen, where only the first half contains preferences.
I was thinking on including a PreferenceFragment
, but I need to support older devices (min supported API level is 9), and I also need to show the action bar (currently using appcompat library).
According to this question I'm screwed.
So now I need to replicate the look and feel of a preference list.
I've thought on including a ListView
, and code a custom adapter that will provide a different item layout for each one of my "preference" types. I need to emulate CheckBoxPreference
and ListPreference
. The list preference is easy, as I just need to use the default layout for 2 text lines items (android.R.layout.simple_list_item_2
), then show a custom dialog with the options. But I can't find in the built-in resources the layout for the checkbox preference.
I'll manage SharedPrefs on my own.
Questions:
- Is there a better way of emulating preferences?
- In case not, how could I copy or even reuse the built-in layout for checked list items? Is it available in android.R.layout? I need my custom adapter to return a layout that looks almost exactly as a
CheckBoxPreference
for boolean-like settings.