i am using a listprefernce in my app and when a user makes a selection I would like to check it for errors, but when i set an onclicklistener it starts when i select the listpreference, not when i make my selection. is there a way to make it check the selection right after they make it?
found the answer. incase anyone else wants to know you need to use setOnPreferenceChangeListener and use the newValue object.
Related
I would like to show the preference value in the summary field. This accepted answer shows how to do it for a ListPreference.
Is there a similar way to do it for an EditTextPrefernce in the layout instead of extending the class?
I just have a little method that updates the preference summary every time a preference changes. I found this somewhere online back when I needed it but unfortunately I don't remember where to credit :(
Edit: Nevermind, I found the source.
https://stackoverflow.com/a/4325239/3238938
I would ask what is name of this UI component:
I need a make something like this in my app., so I will very happy if you answer me :)
It is called as Spinners in android.... here is a link for a tutorial that will help u creating one.
Tutorial Link
You can find the official documentation here
This is a Spinner.
Spinners provide a quick way to select one value from a set. In the default state, a spinner shows its currently selected value. Touching the spinner displays a dropdown menu with all other available values, from which the user can select a new one.
(cf documentation)
I am using a DialogFragment to show a DatePicker to choose a date. The point is that such date could be optional, so somewhere i should display a checkbox asking to use the date or not. So how would you do such an UI ?.
So far i tried adding a checkbox on the same DialogFragment but i believe the interaction wont be very intuitive because if you choose the checkbox "no date" i would have to block or disable the datepicker but i wasn't able to do that and even if i do i am not sure if it is the best approach.
Have you seen any application solving a problem like this and how does it solve it ?
Here's how I solved it in my app: make it clear on the button that launches the DialogFragment that a date is optional.
After a date is chosen, add the option to remove it. Clicking on the "x" restores the button to look like above.
In my Preference activity, say I have two checkboxpreference. If I select the first one, the second one is enabled, but if I deselect the first one, the second one is disabled.
My question is, if the first one is deselected and someone clicks the disabled second preference (it's greyed out), is it possible to attach a hint to it when disabled to tell the user that they must first select the above preference in order to enable the second one?
I looked in the Preferences API, but could not find anything to match this requirement.
Any tips?
Thanks!
Use the preference's summary as your hint. This will provide some text below the checkbox and its title in smaller print.
By xml:
http://developer.android.com/reference/android/preference/Preference.html#attr_android:summary
By code:
http://developer.android.com/reference/android/preference/Preference.html#setSummary(int)
I have no idea how to achieve this, and don't know if it's achievable or not.
I have a sharedPreference value I set via my android app like this
menu button -> settings -> listPreference (a 1 digit value is set this way, among 3 values!!!)
I would however like to be able to set this value without entering the settings menu first, because it is changed often. Im thinking a button should take me directly to the listPreference dialog box like this!
Button -> listPreference
Is is possible to omit the settings menu like this?
Thanks
I asked somthing similar some time back. There is no quick solution but I have a coded up custom solution in the answer to this question