On my latest project, I needed to add a ‘Filters’ screen for a REST request which would add some query params depending on what the user chose to filter.

The components on this screen would be also specified on an API response and thus they needed to be dynamically created, they couldn’t be loaded from an XML resource.

So I created a small parser for this ‘filter specification’ and tried to build a couple of Fragments with all those components using both native Views and a PreferenceScreen, this last one giving me quite the headache — yes, I know it’s not its intended behavior at all.

Yeah, that looks great…

As you can see, none of the Preferences were actually using the proper layouts. I’ll show you how to fix that.