I have a TextView and a ListView in my layout.I am doing a Filter operation and the results are set in ListView.If the result is null,then i want to set "No results" in my TextView. Is it possible to pass the TextView through the constructor of the Adapter class so that i can set the text if result is null?
I passed my TextView through constructor and checked the result in publishResults and set the visibility accordingly
@Override
protected void publishResults(CharSequence constraint,
FilterResults results) {
try{
filteredModelItemsArray=new ArrayList<MarkerRowItem>();
filteredModelItemsArray = (ArrayList<MarkerRowItem>) results.values;
if(results != null && results.count > 0) {
notifyDataSetChanged();
noResultTextView.setVisibility(View.GONE);
} else {
notifyDataSetInvalidated();
noResultTextView.setVisibility(View.VISIBLE);
}
}
catch(Exception e)
{
e.printStackTrace();
}
}