checkboxpreference

CheckboxPreference onClick()

梦想的初衷 提交于 2019-12-02 07:07:40
问题 I want to implement a 2 part preference screen. If checkbox is clicked, first category should lock and 2nd one unlock. If it's not, reverse. Now I see it only works if I go to previous activity and then to new (sharedPreferences). What listener should I override and how? 回答1: You could try something like: final Preference otherpref = (Preference) findPreference("otherpref"); final Preference pref = (Preference) findPreference("checkbox"); pPref.setOnPreferenceClickListener(new

CheckBoxPreference with own layout

北城以北 提交于 2019-11-28 07:39:57
I have PreferenceScreen with some PreferenceCheckBoxes. I want to change the textColor and textSize for title and summary and the images for the CheckBox checked and uncheckes. So I am using android:layout to change this attributes. My ChceckBoxPreference: <CheckBoxPreference android:layout="@layout/preference_checkbox" android:key="temp" android:title="@string/title" android:summary="@string/summary" android:defaultValue="true" /> When I use android:widgetLayout it looks strange. And this is my preference_checkbox.xml: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

Android CheckBoxPreference Default Value

假如想象 提交于 2019-11-27 20:37:27
I have the following XML code for my CheckBoxPreference : <CheckBoxPreference android:key="pref_boot_startup" android:title="Auto start" android:defaultValue="true" /> But when I retrieve the preference in code the value is false . sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); boolean autoStart = sharedPreferences.getBoolean("pref_boot_startup", true); My autoStart variable returns false . Is there a specific reason for this? Am I missing a step to set the default value to true ? junkdog You have to set the defaults first: @Override protected void onCreate() {

Android CheckBoxPreference Default Value

眉间皱痕 提交于 2019-11-27 04:27:41
问题 I have the following XML code for my CheckBoxPreference : <CheckBoxPreference android:key="pref_boot_startup" android:title="Auto start" android:defaultValue="true" /> But when I retrieve the preference in code the value is false . sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); boolean autoStart = sharedPreferences.getBoolean("pref_boot_startup", true); My autoStart variable returns false . Is there a specific reason for this? Am I missing a step to set the default

CheckBoxPreference with own layout

感情迁移 提交于 2019-11-27 01:56:02
问题 I have PreferenceScreen with some PreferenceCheckBoxes. I want to change the textColor and textSize for title and summary and the images for the CheckBox checked and uncheckes. So I am using android:layout to change this attributes. My ChceckBoxPreference: <CheckBoxPreference android:layout="@layout/preference_checkbox" android:key="temp" android:title="@string/title" android:summary="@string/summary" android:defaultValue="true" /> When I use android:widgetLayout it looks strange. And this is

Android: How to remove margin/padding in Preference Screen

一笑奈何 提交于 2019-11-26 18:45:37
I am facing very weird problem in designing preference screen. Though I am not giving any margin in layout,it is leaving some space in left. As you can see in image below: XML: <PreferenceScreen android:title="demo" > <CheckBoxPreference android:defaultValue="false" android:key="prefSync"` android:title="Auto Sync" /> </PreferenceScreen> Am I doing something wrong in adding check-box preference in screen? Updating this for androidx. After a lot of experimentation, I resolved this issue by adding this to each preference that had the excess indentation: app:iconSpaceReserved="false" Of course,

Android: How to remove margin/padding in Preference Screen

核能气质少年 提交于 2019-11-26 06:32:15
问题 I am facing very weird problem in designing preference screen. Though I am not giving any margin in layout,it is leaving some space in left. As you can see in image below: XML: <PreferenceScreen android:title=\"demo\" > <CheckBoxPreference android:defaultValue=\"false\" android:key=\"prefSync\"` android:title=\"Auto Sync\" /> </PreferenceScreen> Am I doing something wrong in adding check-box preference in screen? 回答1: Updating this for androidx. After a lot of experimentation, I resolved this