checkboxpreference

Android testing preferences fragment by Expresso

ぐ巨炮叔叔 提交于 2021-02-10 05:21:24
问题 I have got a problem with testing my code by Expresso. I wrote this code: public class SettingsActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getFragmentManager().beginTransaction() .replace(android.R.id.content, new SettingsFragment()) .commit(); } public class SettingsFragment extends PreferenceFragment { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);

Android testing preferences fragment by Expresso

放肆的年华 提交于 2021-02-10 05:19:45
问题 I have got a problem with testing my code by Expresso. I wrote this code: public class SettingsActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getFragmentManager().beginTransaction() .replace(android.R.id.content, new SettingsFragment()) .commit(); } public class SettingsFragment extends PreferenceFragment { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);

custom checkbox in checkboxPreference - summaryOn & summaryOf

僤鯓⒐⒋嵵緔 提交于 2020-01-17 04:09:14
问题 I would like to change a default checkboxPreference layout a bit. I use answers from other similar question but still there is one thing that does not work. I've got: <CheckBoxPreference android:key="@string/pref_acceptableads" android:summaryOff="@string/pref_acceptableads_summary_off" android:summaryOn="@string/pref_acceptableads_summary_on" android:title="@string/pref_acceptableads_title" android:widgetLayout="@layout/checkbox_layout" /> and: <?xml version="1.0" encoding="utf-8"?> <!--

CheckBoxPreference - onSharedPreferenceChanged method not getting called

删除回忆录丶 提交于 2019-12-24 06:49:09
问题 I have a couple of CheckBoxPreferences set up, my preference class extends PreferenceActivity and implements OnSharedPreferenceChangeListener This is what I'm using to respond to people checking/unchecking the CheckBoxPreferences : public void onSharedPreferenceChanged(SharedPreferences P, String K) { if (K.equals(CheckBoxPref_KEY_HERE)) { MyClass.BooleanVariable = P.getBoolean("CheckBoxPref_KEY_HERE", true); } } As far as I can tell, the onSharedPreferenceChanged method above is never even

Show extra info for Preference screens when CheckboxPreference summary field is not enough long?

最后都变了- 提交于 2019-12-21 03:00:34
问题 I have a screen where you can enable/disable modules for my Android application. For this I use a CheckboxPreference screen. This is all good, but the summary field gets cut off if longer descriptions are added than 2 lines. Suppose I have 4-5 lines of description available for each module, I would like to display this in a helper window. I tried to bind a click event to the CheckboxPreference, but that fires for the whole line, so not only when the checkbox is clicked, and more, wherever you

Best way to update checkbox prefefences

谁都会走 提交于 2019-12-12 05:39:11
问题 I was coding a clock for android. For it, i set a function which updates screen 1 time each a second, so my program can consume a lot of resources, and my objective is to add a checkbox preference, consuming the less resources as I can. Then, my question is: I have seen some ways to update preferences with onSharedPreferenceChangeListener for example... Which is the way which consumes less system resources? How should I implement it to my code? 回答1: if you are using a PreferenceActivity you

Start/Stop service by checking/unchecking CheckBoxPreference

自闭症网瘾萝莉.ら 提交于 2019-12-10 10:26:23
问题 i'm writting an app that start or stop service by checking or unchecking CheckBoxPreference i tried to find some information such as sample code or tutorials. but i didn'f find yet. how to start or stop service by checking or unchecking CheckBoxPreference which is in PreferenceActivity ? i want to start service when "service_toggle" key is true and stop service when "service_toggle" key is false Are there any sample code or tutorial about Start/Stop service by checking/unchecking

Start/Stop service by checking/unchecking CheckBoxPreference

╄→гoц情女王★ 提交于 2019-12-05 21:25:37
i'm writting an app that start or stop service by checking or unchecking CheckBoxPreference i tried to find some information such as sample code or tutorials. but i didn'f find yet. how to start or stop service by checking or unchecking CheckBoxPreference which is in PreferenceActivity ? i want to start service when "service_toggle" key is true and stop service when "service_toggle" key is false Are there any sample code or tutorial about Start/Stop service by checking/unchecking CheckBoxPreference ? Here is my code : Settings.java package kr.hybdms.sidepanel; import android.content.Intent;

Dynamically create CheckBoxPreferences

落爺英雄遲暮 提交于 2019-12-04 18:40:33
问题 I am currently building out a list of rows with checkboxes dynamically using content from a web service. However, this ListView will need to do pretty much what a PreferenceActivity would accomplish. I don't know the number of rows as the content is dynamic so I can't create each CheckBoxPreference in XML. How do I go about building a PreferenceActivity that will display an unknown number rows with a CheckBoxPreference dynamically? 回答1: I think you're looking for something like this: public

CheckboxPreference onClick()

痴心易碎 提交于 2019-12-02 07:28:29
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? You could try something like: final Preference otherpref = (Preference) findPreference("otherpref"); final Preference pref = (Preference) findPreference("checkbox"); pPref.setOnPreferenceClickListener(new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { otherPref.setSelectable(false);