I am creating an app in which a user can set some preferences in a PreferencesActivity
and then I got a fragment with a ListView
which is supposed to be filtered according to what the user has chosen. I already got a Filter
which is filtering the list with users text input but I'm not sure how to filter according to preferences made in the PreferencesActivity
.
The data class representing a single list item looks something like this:
public class MyData
{
private ArrayList<SomeEnumType> enumListMember;
private String forRegularStringFilter;
...
}
public enum SomeEnumType
{
VAL1,
VAL2,
VAL3
}
What the user sees in the preferences is a MultiSelectListPreference
with entries VAL1, VAL2, VAL3, and the user can select several of them. After the user finishes his selection, the list is suppose to show only the items which its enumListMember
contains all the enum values the user has chosen. for example, the list of the class can contain VAL1 and VAL3 so if the user is choosing VAL3, the item is supposed to show. If he chooses VAL2, it's supposed to be filtered.
How and where do I make this kind of filtering? in the Adapter's getView
? somewhere else?
What I eventually did was simply creating a new adapter with the correct values and replacing the old one every time a filtering was needed.