android-preferences

ListPreference with a max number of selectable options

I want to have an element in my preference menu that does the following: Show a list of options. Many are selectable Maximum amount of options to be chosen 2. Possibilities I thought of: Doing a separated PreferenceScreen and showing options as checkBoxes but I don't know where to place the logic of max 2 options. Extending DialogP...

OnPreferenceChangeListener for every setting

I know that I can do something like this: Preference pref = findPreference(getString(R.string.pref_vibrate_on_key)); pref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { LogUtil.d("Working!"...

Changing state of CheckboxPreferece - android

Is there any way to change state of CheckBoxPreference in code? Or can I refresh it to show good value of preference? ...

Problems calling Android's getSharedPreferences(); from SQLiteOpenHelper class

Hi, First I want to describe my situation briefly. I have two classes, one MainClass and one DataBaseHelper class, which extends SQLiteOpenHelper. From my MainClass I call a method in the DataBaseHelper class to open a data base. Before opening the data base I want to check the users data base version (this is important as soon as I ...

android: using listpreference and retrieving key string...

I have a settings menu that pops up and in it is a listpreference type menu. It is associated with a settings.xml file where there are 'array-strings' within it. It all works good but I don't know how to retrieve the users preference. As an example, let's say the user picks a color (red, green, or blue). The list that I've made within m...

Using listpreference and getting the key works but no ok button...

I'm using listpreference in my android app and getting my key values and all is well and works good (now that you guys have helped me) BUT - when my listpreference menus popup, they only contain a cancel button. Let's say the user is choosing between red, blue, and green. When the listpreference dialog first pops-up, the dialog only sho...

PreferenceActivity and theme not applying

Hi all I have set the theme in the manifest file like this: android:theme="@android:style/Theme.Light" But I have a problem in the Preferences Activity, in the main preferences the theme shows ok, but if I get to a sub preference, the theme gets messy, it is not white as it should, it is all dark, and the font is black so you can't se...

Android: After changing a preference (a setting), text showing settings doesn't update...

I will try to explain a simple app scenario: My app goes right to a 'main view'. In this main view I have inserted a 'TextView' which displays current settings created by way of the PreferenceManager. For simplicities sake, let's say I have a checkbox in my settings. When I first start my app - the TextView on my main view shows my check...

How to enable a preference in my android application when other preference is disabled ?

Hi, I have used PreferenceActivity to have preference in my android application. I want one preference say "pref 2" to be enabled when other preference say "pref 1" is NOT checked and "pref 2" to be disabled when "pref 1" is checked. i.e. exactly opposite of the android:dependancy attribute. How can I do that? ...

How to add a button to PreferenceScreen

Is there any way to add a button to the bottom of preferences screen and make them work correct when scrolling? ...

How get an Android ListPreference defined in Xml whose values are integers?

Is it possible to define a ListPreference in Xml and retrieve the value from SharedPreferences using getInt? Here is my Xml: <ListPreference android:key="@string/prefGestureAccuracyKey" android:title="@string/prefGestureAccuracyTitle" android:summary="@string/prefGestureAccuracyDesc" android:entries="@array/prefNumberAccuracyLab...

Get preferences in AppWidget Provider

Hi all, 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", fa...

Android: SharedPreference: Defaults not set at startup...

I have Listpreferences in my app. They don't appear to be setting to their defaults right after installation - they appear to be null. I'm trying to figure out why my default preferences are not being set right after installation. In my main code I have: SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); ...

Emulating Preference look/feel with LinearLayout

I really like the look and feel of the Preference UI items and want to replicate that in my application. Basically I've got an Activity with a couple LinearLayouts set to be focusable. When they are focused, I want them to turn green (like Preferences do). Any idea how to apply that style to my LinearLayouts? Note: The LinearLayouts ...

Default value of Android preference

How do you get the default value of an Android preference defined in XML? Context: I don't want to repeat the definition of the default value in both the code and the preferences XML. ...

how to use PreferenceActivity to modify DefaultSharedPreference in a native way?

ok... I need to put preferences from DefaultSharedPreference to PreferenceScreen in a PreferenceActivity....any native way for doing that? if not any easy and efficient way? ...

Where to store Android preference keys?

When I create preference activity I define all preferences in xml file. Every preference has a key defined in this xml. But when I access preference I write: SharedPreferences appPreferences = PreferenceManager.getDefaultSharedPreferences(this); boolean foo_value = appPreferences.getBoolean("foo_key_defined_in_xml", false); Is there ...

How to open a nested child PreferenceScreen in Android.

Hello, I have a PreferenceScreen that is defined in XML that serves all the preferences for my application. This PreferenceScreen also has a child PreferenceScreen nested within it. My implementing class is called PreferencesActivity. I know I can open the main Preferences window via startActivity(new Intent(this, PreferencesActivity.cl...

Initialize preferences from XML in the main Activity

My problem is that when I start application and user didn't open my PreferenceActivity so when I retrieve them don't get any default values defined in my preference.xml file. preference.xml file: <?xml version="1.0" encoding="utf-8"?> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" android:key="applicat...

How to handle images better in Android

In the microblogging application I am developing I wish to show an user image beside each post in the timeline. The images are small in size(max 50*50 dip) and are not more than 10 in number. I've two approaches in my mind. 1) Allow user to chose an image from Gallery on signing up. Send the image to the server and on subsequent signup...