I'm working on a Dialog and getting this error that I'm not sure how to fix. Of course I've searched for others with the same, but the solution given was to change the parent class of the activity. My parent activity is a pretty complicated form with a lot of other dialogs and I really really don't want to touch changing it's parent class. What I ideally want is to find the TextView causing this and change it.
the error:
E/ThemeUtils: View class androidx.appcompat.widget.AppCompatTextView is an AppCompat widget that can only be used with a Theme.AppCompat theme (or descendant).
I've narrowed the problem to a Spinner. Logcat is filled with 7 copies of this error when taping open the Spinner. Note, this spinner has 4 options.
The error does not happen with other spinners either directly on the Activity or on other Dialogs launched from the same Activity. Which makes me think that I should be able to achieve my dream of fixing this with a change to the Dialog I'm currently working on.
The Spinner's logic in the custom dialog fragment class:
private void setUpNavSpinner(View view) {
typeSpinner = view.findViewById(R.id.nav_spinner);
List<CharSequence> typeList = new ArrayList<CharSequence>(
Arrays.asList(getActivity().getResources()
.getStringArray(R.array.repeating_task_options_plural_array)));
ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(getActivity(),
R.layout.row_spinner_simple,
typeList ) {
// show impossible options as grey
@Override
public View getDropDownView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
View mView = super.getDropDownView(position, convertView, parent);
TextView mTextView = (TextView) mView;
int type = position + 1; // spinner is 0-based and types are start at 1=daily
if (isTypeValid(type)) {
mTextView.setTextColor(Color.BLACK);
} else {
mTextView.setTextColor(Color.GRAY);
}
return mView;
}
};
// Apply the adapter to the spinner
typeSpinner.setAdapter(adapter);
// Set initial value to weekly
typeSpinner.setSelection(getTypeSpinnerIDFromRTType(rt.getType()));
// Respond to user clicks
typeSpinner.setOnItemSelectedListener(this);
}
Spinner's XML
<Spinner
android:id="@+id/nav_spinner"
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="50dp"
android:background="@drawable/boarder_accent_bg"/>
row_spinner_simple.xml
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
style="?android:attr/spinnerItemStyle"
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"/>
I'm quite lost, so please let me know if I'm not including important info and I will quickly add it. Thanks in advance for any assistance!