I am trying to add an ImageView to a preference fragment to show a preview of a color setting. I access the instance of the image using the onCreateView method to adjust the color of the test and it will be displayed. However, it only works if I do not call addPreferencesFromResource in the onCreate method, which is a problem since preferences must be added. Also, if I leave the addPreferencesFromResource call but delete the entire onCreateView method, the program will start (albiet without an updated image).
Error in both cases: "Content has a view with id attribute" android.R.id.list, which is not a ListView class "
I tried to access the image view from onCreate, but by then the layout elements were overpriced and I could not access the actual instance that was being displayed.
LogCat Error:
04-11 00:42:43.619: E/AndroidRuntime(5362): FATAL EXCEPTION: main 04-11 00:42:43.619: E/AndroidRuntime(5362): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.android.signalwidget/com.example.android.signalwidget.SignalWidgetConfigure}: java.lang.RuntimeException: Content has view with id attribute 'android.R.id.list' that is not a ListView class
Here's the PreferenceActivity with inline fragment:
public class SigConfigure extends PreferenceActivity { private static int prefs=R.xml.pref_widget_colors; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
Here is the preference definition in pref_widget_colors
<?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" > <Preference android:key="wifi_signal_color" android:title="WiFi Signal Color" > <intent android:action="android.intent.action.VIEW" android:targetClass="com.example.android.signalwidget.colorpicker.PickerActivity" android:targetPackage="com.example.android.signalwidget" /> </Preference> <Preference android:key="cell_signal_color" android:title="Cell Signal Color" > <intent android:action="android.intent.action.VIEW" android:targetClass="com.example.android.signalwidget.colorpicker.PickerActivity" android:targetPackage="com.example.android.signalwidget" /> </Preference> </PreferenceScreen>
Here is the layout containing the image in layout_pref_row.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <ImageView android:id="@+id/color_preview" android:layout_width="50dp" android:layout_height="50dp" android:layout_marginTop="5dp" android:background="#aaa" /> </LinearLayout>
Despite the error, I do not use ListView or ListFragment anywhere in my project. It almost looks like an Android bug. Any suggestion would be appreciated.