I need to set the selected item on a spinner using the value of a String. At the moment I use this (hint found here: Set selected item of spinner programmatically).
Spinner nudSpinner = (Spinner)nud.findViewById(R.id.spinUnity);
EditText nudEText = (EditText)nud. findViewById(R.id.etxtUnityName);
nudSpinner.setSelection(((ArrayAdapter<String>)nudSpinner.getAdapter()).getPosition(unities.get(position).split(" ")[0]));
It works fine but it gives me the following warning:
Unchecked cast: 'android.widget.SpinnerAdapter' to 'android.widget.ArrayAdapter<java.lang.String>'
Signals places where an unchecked warning is issued by the compiler, for example:
void f(HashMap map) {
map.put("key", "value");
}
Hint: Pass -Xlint:unchecked to javac to get more details.
How can I solve the warning?
Thanks