Android Settings app preference files - android

I've read Android's settings tutorial, and want to use the new "headers" feature in order to accomplish something like the left image. To be exact, I want to have a global "enabled" checkbox, and below it some preference headers surrounded with a category header.
Can I make it be just by using XMLs ?

Yes it is possible by writing your own adapter class that handles headers. I found this nice pretty straightforward example for native settings looking like preference.
It's working on handset but it's not fixed for tablet (app crashes as it tries to use two-pane layout).

Related

Is there UISwitch settings control in Android like iOS

I took a look at the preference activity that Android use for settings. i'm looking for something like UISwitch as shown in below image, does Android have one like this.
I can see the nearest control on Android preference settings is "list preference"
There is ToggleButton and CompoundButton (one extends the other).
But those have a different default display widget then what you are looking for. However either could be used along with your own drawable resources to create the "switch" type control that you are after.
But by default no the system does not include a widget that serves this function and looks the way you want it to.
No, In Android its called ToggleButton.
But still it can be developed by extending RadioButton placed in RadioGroup and giving its UI way you wanted.

Howto make a layout similar to the ones in settings

I have an android Activity where I need to have the user enter some information. The data lends itself to something like a PreferenceView with ListPreferance elements. I am sure that I could use the preferences interfaces to get what I need, but it would by cludgy. Is there a way to get these same widgets in a regular view?
I recently solved this same issue by following a similar approach to the one listed here. It boils down to providing a preference XML to your PreferenceActivity and then backing it with your own Model, instead of the default sharedPreferences. In the example he uses a database but if you don't have a backing database (or you don't want to commit whenever a setting is changed) you can use a Map for backing the Editor.
You want to look at http://developer.android.com/reference/android/R.layout.html: this has all the layouts that are publicly available.
If you're in the mood to dig into the platform bits, look in your <ANDROID SDK FOLDER>/platforms/<platform number>/data/res/layout for the preference*.xml files. This actually has all the individual widgets. You'd have a messy time digging under the hood to figure out which Views to bind callbacks to and to fetch values from, but you could assemble an Activity that looks astonishingly like a PreferencesView but uses whatever source data you choose.

Creating 'settings' view equivalent to the system views

I'd like to create a 'settings' tab in my Android application which will look like views in Android's system settings - for example like a Phone settings > Sound.
I'd like to achieve that headers, checkbox/radio list elements but I have no idea how to bite that.
When I create that UI elements in my XML definition of UI, they does not looks well.
Please suggest me a correct way to do that ane provide me some examples.
The magic word to search is preference
A random link to set you up : http://www.kaloer.com/android-preferences

How to set a layout using spinner

I want to create a layout like the below picture. How can I set the drop-down like this with cancel option. I am using spinner to show the drop-down but cannot set the layout like this.
Can anyone help me to create a drop-down like this. I also want to create an expand button for a list item which will open the content in a new page. My aim is to set all the available settings in a single page.
Then use PreferenceActivity. In fact, that's a standard preference screen.
http://developer.android.com/reference/android/preference/PreferenceScreen.html
http://jetpad.org/2011/01/creating-a-preference-activity-in-android/
You can take a look at the API Demo app which is in the Android SDK. There you can learn how to create this kind of screens (either from XML or code). It has many advantages... for instance, you won't have to worry about persisting the settings... the OS will do that for you.

ListPreference - Custom items possible?

I'm trying to add an image / icon to certain entries of a ListPreference alongside the text.
I would like achieve this programmatically.
Here's an excerpt of the preferences.xml
<ListPreference
android:key="prefGameMode"
android:title="#string/pref_game_mode"
android:summary="#string/pref_game_mode_desc"
android:defaultValue="fourChallenge"
android:entries="#array/arrGameMode"
android:entryValues="#array/arrGameModeValues"
android:negativeButtonText="#string/cancel" />
...
The goal here is to illustrate that some of the options listed are unavailable/ locked in the current version of the app. However, the code-base is used as a library, so I would like the solution to work via code, rather than xml.
Any ideas how to do this? Thanks.
Preferences already gives you a way to indicate that an option is unavailable: just set enabled properly.

Categories

Resources