Android: Possible to attach a hint to a disabled preference? - android

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)

Related

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.

Android : Editing values using alert dialog

In my application I currently have an xml layout that is re-used to enter information 6 times (these are turns in a game). This works fine. At the end of the round I present a screen that has a summary of each turn. I want to implement a button beside each turn to "edit" that turn. There are 3 possible things that can be edited. Ideally an alert dialog or something like a "popup" would be idea for this.
Would I be best off to have 3 buttons per "turn" for editing or is there a way to do this with a popup?
Thanks for your input on this matter.
You could list each turn and it's information with a single edit button next to each. When the edit button is pressed, create a new activity (intent) that prompts for all three pieces of data.
You have several options (and probably more I'm not thinking about). If these are in a ListView (or even if not) you could use a ContextMenu. You could have options in here to change the selected item or others. This would show a popup when the user long clicks the item
A PopupMenu can give you a similar effect that can pop up a list of options when the user clicks on a Button. Note that this requires API >= 11
You also could use an AlertDialog, as you mentioned. But just from what little I know about what you are trying to do I'm not sure this is what you would want.
Again, I don't know enough details about what you have or want but I would say that one of the first two options would suit you best. As far as one Button or multiple Buttons, that depends on the layout that will work best for your app, I suppose. You certainly could have one "Edit" Button which uses something like a PopupMenu and allows the user to choose what to edit. I hope this helped a little.

Android:: Highlight a non-selected button

I am working on a game project.
I have 4 buttons on my screen. User has to select one of the 4. If user selects the correct one, it works fine. but if user selects incorrect one, I want to highlight the correct answer even though user didnt clicked it.
I have presentation due tomorrow. Can anybody point me to some example source or explain it here, as to how can I accomplish it.
You can set the correct buttons background color or image while clicking other buttons
Whenever user clicks on the incorrect button simply call :
correctButton.setPressed(true)
This will highlight the correct button as per your requirement.
you can do one thing..
Call Button.requestFocus() method to get the focus.
Create a custom selector for you Button's background. there
< item android:state_focused="true" android:drawable="#color/your_color" />

Android: Button representing "get my position!"

I have a EditBox, and on right side of this EditBox I wan't to put a Button representing "Get My Position".
User clicks on this button, and my application get his position and fills EditBox with it.
I found a Compass and added on a ImageButton, but I don't know if this really represent the idea.
Anyone knows a better button to represent "Get My Position"?
Thanks
Your Button looks ok, and will be recognized by most users. If you want to get the System-default (the picture of the Drawalbe may differ on roms from HTC, Samsung Motorola etc) you can get it with
getResources.getDrawable(android.R.drawable.ic_menu_location)
Always check for non-Null here. You can download the standart Android location Button here, (ic_menu_location), as a fallback, if the getDrawable() call fails
I used a 'globe' in my application. If the EditBox is blank until the user requests their location, why not use the put some default text inside it requesting the user to click the button?

Access a shared-preference listPreference directly, without having to enter the menu first! (Android)

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

Categories

Resources