Combo preference in Android - android

My desired custom preference looks very much like the out-of-box EditTextPreference, only that it behaves like a "split button" which combines two Preferences: if user clicks on the text on the left, the edit text dialog pops up; which allows user to set the "label" for the preference; if user clicks on the button on the right, another window pops up that allows user to set the "date" for the preference.
I guess I could extend EditTextPreference but I am not sure how I can maintain two separate keys for a single preference control (or "widget" in Android's term). Or is it possible to "mix up" two Preferences without subclassing?

Really you do not have to use the built in preference widgets to manage your preferences; for example, in my application, i use a PreferenceScreen to bring up a multiple selection dialog with a custom listview/adapter. If you wish to handle your own key/value store, you could bind to the preference with findPreference(), set the value in the PreferenceActivity's onCreate() and persist the value in the activity's onPause(). Examining the key / value preference store can be done via getSharedPreferences(file,MODE.PRIVATE) and an associated getter method. To edit them, take the SharedPreferences object that's returned and call edit() / commit() on it once changes have been made.
Does this answer you question?

Related

Is there a way to put a clickable icon next to a Preference?

I am remaking our custom preferences screen into PreferencesScreen.
We currently have several settings, for example checkboxes, with a questionmark icon next to it that users can click to get information about the setting.
The built-in preferences have "setIcon" which works, but it does not seem possible to make them clickable.
Is the only solution to make totally custom layouts for my preference, or is there some other way to have a clickable image or icon next to my preference rows?

Reset settings option in PreferenceScreen

I checked different options that are available in PreferenceScreen (eg. CheckBoxPreference, EditTextPreference, etc.) but non of them give me the possiblity to obtain a simple dialog with just 2 buttons. I would like to use it to implement a basic “Yes, reset my app” / “Cancel” features. How to make this preference option easily?
Its tricky check this answer.
Well I've implemented EditText Preference which shows 2 buttons ok and cancel but in middle there is Edittext.

Create Android preference in settings to set password

I would like a setting in preferences that allows the user to create a password. The perfect example is in the Play Store. In settings you click on Password and a dialog box pops up with an EditText field with a password field that hides the characters. How would you do that?
I'm pretty sure this is not EditTextPreference. Is this a custom preference? How would you make this? Can I get a sample for the XML part of it?
I'm pretty sure this is not EditText preference
EditTextPreference would work. Quoting the documentation:
This EditText can be modified either programmatically via getEditText(), or through XML by setting any EditText attributes on the EditTextPreference.
So adding android:password="true" as part of your preference XML should work.
That being said, you are certainly welcome to create your own custom DialogPreference for this.
Using intents
In some cases, you might want a preference item to open a different activity instead of a settings screen, such as a web browser to view a web page. To invoke an Intent when the user selects a preference item
it's available at android guide, check this link
http://developer.android.com/guide/topics/ui/settings.html#Intents

How to have custom dialog on preference activity?

I have a preference page where there is a check box preference for enable login password. When the user check it, it should have a dialog pop out and inside there will be 2 edit text fields for password.
I have done some readings and it seems like using a custom dialog will be the right choice. But the problem is that there is no onCreateDialog() method for the preference activity to override, how do I solve this problem?
Some example codes will be nice. Thanks!
Create your own custom subclass of DialogPreference that handles your dialog and persists your preference value, and use that in your preference XML resource.

Properties grid on Android - readonly and/or editable

I need to create a properties grid in my application to allow the user to read (initially) and eventually edit the properties of an object that I display using a custom list adapter.
I did some research and found that Android has the preferences activity, which sounds good as far as the UI portion, but I don't want to actually save "preferences", I need an edit screen.
Is there a way to have a dialog created which will use reflection (sorry, .net term) to create the dialog allowing the user to edit each property of an object, or do I need to create this manually? Either is ok, I just need to know. Thanks!

Categories

Resources