Creating a standard Android preferences dialog

New Android developer here - I'm hoping this is simple. I want to create a "row-based" prefs dialog, like you see in most standard apps. You know, black background, fading-line separators, bigger/bold label text for each entry, smaller description text, perhaps a checkbox/down arrow.

Is there a standard object in the Android API for this? If not, how do people usually create these?


Asked by: Charlie469 | Posted: 25-01-2022






Answer 1

Yes, there is a special Activity for that kind of view called PreferenceActivity.

You can find a full example here.

HTH

Thomas

EDIT: this example is a code based preference dialog, but there is another way to do with the xml layout file.

Answered by: Emma133 | Posted: 26-02-2022



Similar questions

Android preferences exception

When I execute the following code: Preferences.userRoot().nodeExists(strNodeName); I get an exception : java.util.prefs.BackingStoreException: Cannot get children names for User Preference Node: /! Any idea ?


Changing android widget setup preferences after creation?

Say my app has a widget and I use a configuration screen to do initial app widget setup and set a few preferences. I want the user to be able to change those settings by simply going into my app's settings screen and clicking an intent preference to open up the same options the user was given when the app was created. Can I use the same activity as the configuration activity? Will I have to handle it diffe...


Dismiss android preferences dialog on Keyboard ACTION_DONE press

I would like to be able to close the editpreference dialog (as shown here http://twitpic.com/18ttdp) by pressing the 'Done' button on the keyboard. Currently, pressing 'Done' just dismisses the keyboard but leaves the dialog. In other parts of my application I use code similar to the following to intercept the 'Done' key press and execute ac...


Multiple instances of the same android widget: Anyway way to have instance specific preferences?

I am creating a simple Android widget with a typical usecase of having many instances of it running at once. Using the stock preferencesmanager, it seems each instance of the widget shares the same preferences. Is there any way to not have this happen? Thanks!


resources - Using icons in Android preferences

I would like some of my preferences to have icons, like the Settings app. I guess one way of doing this would be to copy all the relevant code and resources from the Settings app, but it seems like overkill for a couple of icons. Also I don't like the idea of having to duplicate the code and resources in each project that requires settings icons. Has anyone solved this already with a simpler or res...


android - Get preferences in AppWidget Provider

I seem to be having trouble reading preferences from my AppWidgetProvider class. My code works in an Activity, but it does not in an AppWidgetProvider. Here is the code I am using to read back a boolean: SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); boolean autoreplyon = settings.getBoolean("autoreplyon", false); However, I get the "The method getSharedPreferences(Strin...


android - Initialize preferences from XML in the main Activity

This question already has answers here:


Can we use preferences accress multiple different acvtivities in android?

I save preferences in one activities but not able to get saved preferences in other activity. I can access saved preferences in the same activity but not in other one. It is not giving me any error but always gibing null values in second activity. Below is the code: First Activity: public static final String PREFS_NAME = "MyPrefsFile"; SharedPreferences.Editor ...


variables - How do I get preferences to work in Android?

I've really been struggling through this. New to Java/Android. I'm writing my first app and this is the first thing that has taken me longer than a couple days of searching to figure out. Here's the setup: It's a BAC calculator / drink counter: A formula is used to calculate the BAC. Here's the forumla: Bac = ((StandardDrinks / 2) * (G...


android - Is using Shared Preferences for storing user data reliable?

Will the data still be there after the user restarts his / her phone or changes SIM / battery?






Still can't find your answer? Check out these communities...



Android Google Support | Android Community | Android Community (Facebook) | Dev.io Android



top