preference

Custom DatePicker as Preference does not keep value when user edits value in field

旧城冷巷雨未停 提交于 2019-12-03 00:35:17
I created a DatePickerPreference, i.e. I extended DialogPreference and created a DatePicker object inside and had it working almost perfectly. It changes values when you click the arrows up and down and saves the value you select. However, if you click inside the field and types the new value there, it doesn't save the updated value! When using the arrows, the onDateChanged() method is always called; when user enters the field and edits it, it will only call onDateChanged if he selects another field (and in this case, if he edits the last field and just hit OK, the last edit will be ignored).

Can I perform database specific operation using android.preference package?

社会主义新天地 提交于 2019-12-02 00:45:43
I need a database in which I can store data and get data whenever I need. Is this possible with android.preference package. I do not want to use sqlite database regards According to Shared Preferences | Android Developer Tutorial (Part 13) by Sai Geetha M N, Many applications may provide a way to capture user preferences on the settings of a specific application or an activity. For supporting this, Android provides a simple set of APIs. Preferences are typically name value pairs. They can be stored as “Shared Preferences” across various activities in an application (note currently it cannot be

Preferences of varying height within a PreferenceActivity

给你一囗甜甜゛ 提交于 2019-12-01 17:43:53
I have a custom class that extends Preference that I'm using in conjunction with a PreferenceActivity. When I try to adjust the height in the layout my Preference is using (with a static layout_height or with wrap_content) it is always displayed in a uniform height cell in the Preference Activity - the same size that all of the "normal" preferences default to. Is there a way present a given preference with a different layout_height. I've looked at the API demos related to preferences and I'm not seeing anything that matches what I'm trying to do. theJosh You can override getView(View,

(Activity+preferencefragment) Error inflating class com.android.internal.widget.ActionBarContainer

偶尔善良 提交于 2019-12-01 10:53:59
问题 I have no idea about this error. I got these mesaage from google developer console. Some devices like z3, htc m8 ,m9 can't execute my app. Could someone give me some hint about the error? Stacktrace : java.lang.RuntimeException: Unable to start activity ComponentInfo{package name/package name.SettingsActivity}: android.view.InflateException: Binary XML file line #31: Error inflating class com.android.internal.widget.ActionBarContainer at android.app.ActivityThread.performLaunchActivity

Reload Preferences in PreferenceActivity on Resume

江枫思渺然 提交于 2019-11-30 18:49:22
In my app, some settings can possibly be changed while the PreferenceActivity is not open, and an issue I'm running into is that addPreferencesFromResource is called in onCreate , so say, I open the PreferenceActivity , then go to another screen from there, then do something that changes the settings, then hit the back key to go back to the PreferenceActivity , then certain settings have not changed on the layout. So, how could I re-load all the Preferences every time onResume (or onStart() ) is called without duplicating the layout? edit: This solution will work for API 11 + only. Im not sure

Create own SwitchCompat Preference

孤人 提交于 2019-11-30 12:54:34
问题 Since the appcompat v7 is missing a SwitchCompatPreference it seems like it's necessary to create it by myself. How can this be achieved? I googled a bit and found a tutorial for a DialogPreference . I tried to adopt it for a SwitchCompatPreference but in my xml layout it always says that this class is not allowed in the preference xml. What do I need to do? 回答1: You do not need to create a new component. First of all, you should use CheckBoxPreference instead of SwitchPreference, in order to

Android preference summary . How to set 3 lines in summary?

笑着哭i 提交于 2019-11-30 12:53:45
Summary of preference is allowed only 2 lines . If I want to display 3 lines or more in summary . How can I do ? You can create you Preference class by extending any existing preference: public class LongSummaryCheckboxPreference extends CheckboxPreference { public LongSummaryCheckboxPreference(Context ctx, AttributeSet attrs, int defStyle) { super(ctx, attrs, defStyle); } public LongSummaryCheckboxPreference(Context ctx, AttributeSet attrs) { super(ctx, attrs); } @Override protected void onBindView(View view) { super.onBindView(view); TextView summary= (TextView)view.findViewById(android.R.id

PreferenceFragment background color

别来无恙 提交于 2019-11-30 10:58:26
I am using a PreferenceFragment (without a ListView ), but am unable to set the background color, and it seems to be transparent. How can I set the background color to white with PreferenceFragment ? EDIT: first screenshot: Overriding onCreateView not work - Josh Larson This question was also answered here Adding the following code to your PreferenceFragment will let you add a background color, image, etc. @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = super.onCreateView(inflater, container, savedInstanceState); view

Create own SwitchCompat Preference

梦想的初衷 提交于 2019-11-30 04:05:50
Since the appcompat v7 is missing a SwitchCompatPreference it seems like it's necessary to create it by myself. How can this be achieved? I googled a bit and found a tutorial for a DialogPreference . I tried to adopt it for a SwitchCompatPreference but in my xml layout it always says that this class is not allowed in the preference xml. What do I need to do? You do not need to create a new component. First of all, you should use CheckBoxPreference instead of SwitchPreference, in order to support lower APIs. Using the existing android.support.v7.widget.SwitchCompat widget, create a new layout

Reload Preferences in PreferenceActivity on Resume

 ̄綄美尐妖づ 提交于 2019-11-30 03:41:16
问题 In my app, some settings can possibly be changed while the PreferenceActivity is not open, and an issue I'm running into is that addPreferencesFromResource is called in onCreate , so say, I open the PreferenceActivity , then go to another screen from there, then do something that changes the settings, then hit the back key to go back to the PreferenceActivity , then certain settings have not changed on the layout. So, how could I re-load all the Preferences every time onResume (or onStart() )