最初にonQueryTextChange()でこのメソッドを呼び出します。下記参照。 filterListByPattern()において
@Override
public boolean onQueryTextChange(String s) {
filterListByPattern(s, List);// List is TextView Large amount of data convert each word as a list item.
return true;
}
、
private void filterListByPattern(String s, ArrayList<String> mainList)
{
for(int i = 0; i < mainList.size(); i++)
{
String word = mainList.get(i);
if(word.toLowerCase().toString().contains(s.toLowerCase().toString()))// if search word found in list
{
Spannable wordtoSpan = new SpannableString(word);
wordtoSpan.setSpan(new ForegroundColorSpan(Color.BLUE));// change the color of the word in to blue.
mainList.set(i, wordtoSpan.toString())//color changed word update to the List.
break;
}
}
for(int i = 0; i < mainList.size(); i++)
{
String word = mainList.get(i);
tv.append(word);//append each word in List. search word will be blue color
}
}