I'm getting this message while building my project:
...\listadapter\MyAdapter.java:
uses unchecked or unsafe operations.
Recompile with -Xlint:unchecked for details.
This happens for this lines of code:
@Override
protected void publishResults(CharSequence constraint, FilterResults results) {
beanList = (ArrayList<Bean>) results.values;
notifyDataSetChanged();
}
I have no clue what to do.
That's because you are casting to a generic type, and the compiler don't know if this casting is legal. If your results.values
isn't an instance of ArrayList, this line of code will fail with a ClastCastException.
But if it is, compiler will cast the value, but it can't check what the type of generic parameter is, and if your variable holds ArrayList with strings inside, your line of code won't fail, but it will at another one, where you are reading from the list.
If you are 100% sure it will be an ArrayList of Bean you can just suppress this warning (by annotating the method with @SuppressWarnings("unchecked")