public void filter(String charText)
{
charText = charText.toLowerCase(Locale.getDefault());
dataOrig.clear();
if (charText.length() == 0)
{
dataOrig.addAll(arraylist);
}
else
{
for (User wp : arraylist)
{
if (wp.name.toLowerCase(Locale.getDefault()).contains(charText))
{
dataOrig.add(wp);
}
}
}
//check if the list is correct... it is :/
for (int i = 0; i < dataOrig.size(); i++)
{
Log.i(tag, dataOrig.get(i).name);
}
notifyDataSetChanged();
}
然而,notifyDataSetChanged();使错误的项目出现在列表视图中;即使for循环显示正确的项目被放入dataOrig。