Search code examples
androidandroid-preferences

error: Error: String types not allowed (at 'entries' with value 'array/list')


I am new in android development and developing pref.xml (resource type prefrence) using eclipe software. Here is my pref.xml code

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >

<EditTextPreference
 android:title="EditText"
 android:key = "name"
 android:summary="Enter Your name"
 ></EditTextPreference>

 <CheckBoxPreference
 android:title="CheckBox"
 android:defaultValue="true"
 android:key="checkBox"
 android:summary="check this box"
 ></CheckBoxPreference>

 <ListPreference
 android:title="List"
 android:key="list"
 android:summary="This Is A List To Choose From"
 android:entries="array/list"
 ></ListPreference>

and i got this error :

error: Error: String types not allowed (at 'entries' with value 'array/list')

Please help me.. how do i handle this error ?


Solution

  • Find file name strings.xml in res\value folder in your package explorer... add following line in this file

    <string-array name="list"></string-array>
    

    Your Final file look like

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
    
    <string name="app_name">Muzafar Khan</string>
    <string name="action_settings">Settings</string>
    <string name="hello_world">Hello world!</string>
    
    <string-array name="list"></string-array>
    

    Now save your project... and enjoy :)