我的偏好活动有些问题。代码在预览时显示屏幕完美,但是当我在模拟器上测试时,它在SwitchPreference上显示额外的填充,并且开关不起作用。
除此之外,在棒棒糖前仿真器上进行测试时,根本没有余量。
我的代码:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<SwitchPreference
android:title="Tema"
android:key="night_mode"
android:summary="Ativar tema escuro"/>
<CheckBoxPreference
android:title="App Update"
android:defaultValue="true"
android:summary="This option if selected will allow the application to check for latest versions."
android:key="app_update"/>
<Preference
android:title="Clean cache"
android:summary="Resetar preferencias do app"
android:key="clean_cache"/>
<PreferenceScreen
android:title="Sobre">
<intent android:targetClass="llamaze.com.br.whattodraw.Activitys.AboutActivity"
android:targetPackage="llamaze.com.br.whattodraw"/>/
</PreferenceScreen>/
</PreferenceScreen>
public static class PrefsFragment extends PreferenceFragmentCompat {
Context context;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
Preference customPref = findPreference("clean_cache");
customPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
showDialogCache();
Log.d("PREFRE", "onPreferenceClick: foi clicado");
return false;
}
});
}
答案 0 :(得分:0)
嗯,google通过更新preference-v7到24.1.1
解决了这个问题