views:

62

answers:

2

I'm currently writing a live wallpaper for Android and it has a PreferenceScreen which currently contains only one preference - a DialogPreference to set various properties of animation.

User workflow to configure it currently looks like this: Settings... => (shows the preferences list with only one title ) Animation speed => MyDialogPreference

What I want is to make the workflow like this: Settings... => MyDialogPreference

I.e. I'm looking for a way to skip showing that preferences list with only one item and to show that dialog right away.

But it seems that PreferenceActivity requests itself to have PreferenceScreen as a root element of preference hierarchy. So... is it even possible to do what i want? :)

Code references:

Activity code:

public class ForestLakePreferences extends PreferenceActivity
{
    protected void onCreate(Bundle savedState)
    {
        super.onCreate(savedState);
        getPreferenceManager().setSharedPreferencesName(
                ForestLakeWallpaper.PREFS_NAME);
        addPreferencesFromResource(R.xml.preferences);
    }
}

Prefs resource:

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:key="lake_preferences">
    <DurationEditDialog
            android:title="@string/prefs_duration_title"
            android:dialogTitle="@string/configure_durations_dlg_title"
            android:dialogLayout="@xml/set_durations_layout" />
</PreferenceScreen>
A: 

A DialogPreference has a showDialog(Bundle state) method, try calling it. I am not sure if you will have to give it anything else like the Preferences or anything.

Ryan Conrad
+1  A: 

It turned out this can't be done in that way.

But i've found a workaround: i made my activity not a PreferencesActivity, but a custom one and made it look like dialog by placing the following in AndroidManifest.xml

<activity android:theme="@android:style/Theme.Dialog" .... />
dpimka