In an Android project inside res/xml/ file name pref_visualizer.xml
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<SwitchPreferenceCompat
android:defaultValue="@bool/pref_show_bass_default"
android:key="@string/pref_show_bass_key"
android:summaryOff="@string/pref_show_false"
android:summaryOn="@string/pref_show_true"
android:title="@string/pref_show_bass_label" />
<SwitchPreferenceCompat
android:key="@string/pref_show_mid_key"
android:title="@string/pref_show_mid_label"
android:summaryOff="@string/pref_show_false"
android:summaryOn="@string/pref_show_true"
android:defaultValue="@bool/pref_show_bass_default" />
<SwitchPreferenceCompat
android:key="@string/pref_show_treble_key"
android:title="@string/pref_show_treble_label"
android:summaryOff="@string/pref_show_false"
android:summaryOn="@string/pref_show_true"
android:defaultValue="@bool/pref_show_bass_default" />
</PreferenceScreen>
The SwitchPreferenceCompat text is highlighted and says it cant be allowed here.How to fix this warning. The app runs without any problem. But still I would like to know How to fix this issue.
Try to replace PreferenceScreen
with android.support.v7.preference.PreferenceScreen
in the root tag of your preference XML file (the pref_visualizer.xml in this case).
Your PreferenceScreen's layout cannot be in res/layout/ they have to be in res/xml/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With