I want to have an element in my preference menu that does the following:
- Show a list of options.
- Many are selectable
- Maximum amount of options to be chosen 2.
Possibilities I thought of:
- Doing a separated
PreferenceScreenand showing options ascheckBoxes, but I don’t know where to place the logic of max 2 options. - Extending
DialogPreferenceand doing it by hand.
What’s the best way?
Extending
DialogPreferencewould get you the closest in terms of look-and-feel; thePreferenceclasses are fairly unflexible and un-extendable in my experience.I can’t remember too much about
PreferenceScreen, but I imagine it’s similar.In an app I worked on, we ended up using separate activities, launched via
Intentfrom aPreferenceitem onClick. This allowed us to easily develop preference screens that require validation logic a bit more complex than the usual.