I use Spinner and TextInputEditText in my app that I would like to change some EditText features(Cursor and HintText color) when user selects spinner item. Here is my code:
private void setSpinner(){
String [] types = {"q_a", "attention", "reminder", "explain", "important", "image", "voice"};
TypeAdapter adapter = new TypeAdapter(getActivity(), types);
spinner.setAdapter(adapter);
int [] colors = {
R.color.actual_purple, R.color.actual_pink, R.color.actual_orange,
R.color.actual_carrot, R.color.actual_green,
R.color.deep_blue_grey_flat_icon, R.color.deep_blue_grey_flat_icon
};
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
setTextEditor(colors[position]);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
}
@SuppressLint("NewApi")
private void setTextEditor(int color){
Drawable unwrappedDrawable = AppCompatResources.getDrawable(getActivity(), R.drawable.important_cursor);
Drawable wrappedDrawable = DrawableCompat.wrap(unwrappedDrawable);
DrawableCompat.setTint(wrappedDrawable, ContextCompat.getColor(getActivity(), color));
pointEditor.setTextCursorDrawable(unwrappedDrawable);
pointEditorLayout.setBoxBackgroundColor(ContextCompat.getColor(getActivity(), color));
pointEditor.setHintTextColor(ContextCompat.getColor(getActivity(), color));
}
I don't realize why that's not working. Can someone help me out?