I just finished adding a search feature to my android widget to search through a list of the users installed applications. My app installs fine and everything but when I go to s
Your list contains appInfo.packageName
not appInfo.name
.
In performFiltering method you are adding appInfo.name
to filtered list. Instead you should add appInfo.packageName
.
Your for loop should be like this
for (ApplicationInfo appInfo : originalListAppInfo) {
String somefield = appInfo.packageName;
if (somefield.toLowerCase().contains(constraint.toString())) {
myFilteredAppList.add(appInfo);
}
}
This should work.
And never forget to check for null values in publishResults
method
@Override
protected void publishResults(CharSequence constraint, FilterResults results) {
if(results.values != null)
{
mListAppInfo = (List)results.values;
notifyDataSetChanged();
}
}