[英]Why does my listPreference dialog look different?
I looked at several tutorials and all their listPreference dialogs look like this. 我看了几本教程,它们的所有listPreference对话框都像这样。
listPreference Dialog listPreference对话框
but my dialog looks like this 但是我的对话框看起来像这样
Any ideas why my dialog looks different? 为什么我的对话框看起来与众不同? I reviewed the tutorials and my xml code looks the same as theirs.
我查看了这些教程,并且我的xml代码与它们的相同。
Here is my pref_general.xml code. 这是我的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"
/>
and part of the activity code 以及部分活动代码
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)));
}
I think you are testing in lollipop device. 我认为您正在棒棒糖设备中进行测试。 if you test below lollipop devices, it will look like first one.You can customize it like this ' How to customize list preference radio button '
如果您在以下棒棒糖设备上进行测试,则它将看起来像第一个设备。您可以像这样“ 如何自定义列表首选项单选按钮 ”对其进行自定义
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.