0

我看了几个教程和他们所有的listPreference对话框看起来像这样。为什么我的listPreference对话框看起来不一样?

listPreference Dialog

但我的对话框看起来像这样

my dialog

任何想法,为什么我的对话框看起来不一样?我回顾了教程,我的xml代码看起来和他们的一样。

这是我的pref_general.xml代码。

<?xml version="1.0" encoding="utf-8"?> 

<!-- NOTE: EditTextPreference accepts EditText attributes. --> 
<!-- NOTE: EditTextPreference's summary should be set to its value by the activity code. --> 
<EditTextPreference 
    android:key="@string/pref_location_key" 
    android:title="@string/pref_title_location" 
    android:defaultValue="@string/pref_location_default" 
    android:selectAllOnFocus="true" 
    android:inputType="text" 
    android:capitalize="words" 
    android:singleLine="true" 
    android:maxLines="1" /> 

<!-- NOTE: ListPreference's summary should be set to its value by the activity code. --> 
<ListPreference 
    android:title="@string/pref_temperature_units_title" 
    android:key="@string/pref_temperature_units_key" 
    android:defaultValue="@string/pref_units_metric" 
    android:entryValues="@array/pref_temperature_unit_values" 
    android:entries="@array/pref_temperature_units" 
    /> 

和活动代码

public class SettingsActivity extends PreferenceActivity 
    implements Preference.OnPreferenceChangeListener { 

@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    // Add 'general' preferences, defined in the XML file 
    addPreferencesFromResource(R.xml.pref_general); 

    // For all preferences, attach an OnPreferenceChangeListener so the UI summary can be 
    // updated when the preference changes. 
    bindPreferenceSummaryToValue(findPreference(getString(R.string.pref_location_key))); 
    bindPreferenceSummaryToValue(findPreference(getString(R.string.pref_temperature_units_key))); 

} 

回答

相关问题