簡體   English   中英

為什么我的listPreference對話框看起來不同?

[英]Why does my listPreference dialog look different?

我看了幾本教程,它們的所有listPreference對話框都像這樣。

listPreference對話框

但是我的對話框看起來像這樣

我的對話

為什么我的對話框看起來與眾不同? 我查看了這些教程,並且我的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)));

}

我認為您正在棒棒糖設備中進行測試。 如果您在以下棒棒糖設備上進行測試,則它將看起來像第一個設備。您可以像這樣“ 如何自定義列表首選項單選按鈕 ”對其進行自定義

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM