android-preferences

PreferenceActivity gives a NullPointerException when option selected from ListPreference

Hi all, I'm new to using the PreferenceActivity. Task: Allow user to choose the program layout from the Preferences Problem: Selecting an option in the PreferenceList causes a NullPointerException Exception arises: At android.preference.ListPreference.onDialogClosed() (Shortened) Code: private static final String PREF_LAYOUT_KEY =...

Retain user defined PreferenceScreen structure on android

I am trying to allow users to dynamically create a PreferenceScreen structure at runtime (i.e. users may add/remove certain PreferenceScreen elements such as list items). I then want the PreferenceActivity to not only preserve individual settings but also the preference structure created by the user, even if the app is re-launched. Is th...

Multi select ListPreference on android

Any idea on implementing a multi-select (check boxes) ListPreference on Android? Would I have to extend the ListPreference? Is there any classes already documented to do this? Thanks ...

Modifying styles programmatically

In an Android application I am writing, the styling for my various TextView elements is defined in an xml resource. I would like enable the user to change certain styles such as android:typeface using a PreferenceActivity. Is there a way to modify a style resource programmatically such that all associated widgets will update correctly? ...

ListPreference is throwing a strange null pointer exception

I have an app that obtains a list of available Calendars and displays them in the Spinner. I have checks to ensure that if the available Calendar list is empty, then ListPreference will still display "None available" in the Spinner. I am using the ListPreference to display the Spinner in the Preferences tab. Here is the preferences.xm...

Android how to get specific preference?

I have the following code in my application in res/xml/preferences.xml: <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"&gt; <PreferenceCategory android:title="Wi-Fi settings"> <EditTextPreference android:key="pref_voice_threshold_top" android:title="@string/title_pref_voicetopt...

Android: Force close when trying to call Preferences.java

Hello, Been trying to call Preferences.java class using: Intent settingsActivity = new Intent(getBaseContext(), Preferences.class); startActivity(settingsActivity); I have this in my Manifest.xml (outside the main app class activity): <application> ........ <activity android:name=".Preferences" android:label="Preferences"> ...

Android: Custom Xml Attributes for PreferenceScreen

I use custom xml attributes for preferences. The preferences are inflated from xml. I managed to create and read custom xml attributes for EditTextPreference, ListPreference and CheckBoxPreference by creating custom classes which inherit from the respective preference class. In the constructor of the class I can read the attributes l...

Android Limited Multi Select Preference, why no checkmark?

Hi, I'm trying to create a custom preference for an Android application that limits the number of items the user can select. Once the limit is reached the unselected items should be disabled and only the currently selected items are enabled.. If there are less items selected than the limit all items should be enabled. Here are the two ...

New activity from default preferences

Hi. I have setup my default android Preferences with the necessary options. The prime reason of the Preferences are to allow users to manage their resources. In the context of my app, they are "Contacts", "Types of projects" and "Currency". The "Currency" section works fine. The display just yet, not the programming. But what I really ...

Is it possible to add an array or object to SharedPreferences on Android

If not, is there any workaround? I have an array list of objects that have a name and an icon pointer. I do not want to use a database. ...

Help with Preferences and Android Live Wallpaper

Basically what I want to do is when the preference is switched from the default to whatever to load up a new set of parallax backgrounds. With the code now which is probably over complicated and maybe completely off When I switch my preferences nothing changes. You can definitely tell I'm a novice but, your help would greatly be apprecia...

Android: onPrepareDialogBuilder, onClick & setItemChecked

Hi, I've spent over a week trying to figure out a way to do a Limited Multi Selection Preference list. Nothing I've tried works. I'm ready to give up on Android if something seemingly simple is so hard. I've been programming a long time and don't remember being beaten up this badly by something like this. I have to assume I am not under...

Android: How do I reset/clear application preferences during unit testing?

I want to start with a consistent test environment so I need to reset/clear my preferences. Here's the SetUp for test I have so far. It's not reporting any errors, and my tests pass, but the preferences are not being cleared. I'm testing the "MainMenu" activity, but I temporarily switch to the OptionScreen activity (which extends Andr...

How to return from preference screen to main activity?

Hi. I have one main activity and one preferenceActivity. On my first activity I call menu and go on preferenceActivity by calling startActivityForResult. case R.id.settings: startActivityForResult(new Intent(this, SettingsActivity.class), LAUNCH_SETTINGS); return true; Then I change my ...

Android: How to use Buttons in Preference Screen

I'd like to provide a Button in the PreferenceActivity. The user should be able to set a time (e.g. via TimePicker), but there's no ButtonPreference or something like that. I don't want to use EditTextPreference. So do I have to use a default Button in the PreferenceActivity and save the settings for it manually? Regards, cody ...

Android: How to get the time from a TimePicker when it is typed in

I've got a DialogPreference which implements a simple TimePicker.OnTimeChangedListener (see below). Setting the time by clicking the +/- buttons works great. But I don't know how to save the state of the timepicker when the user typed in the time directly into the textfield. It could be sufficient to access to the current textfield value...