Question

My Google-Fu is failing this Android newbie today.

Does anybody know of a good example showing how to launch an intent from a PreferenceScreen?

Something like:

    <PreferenceScreen
        android:key="preference_some_new_layout"
        android:title="@string/pref_some_title">

            <intent android:action="????" /> 

    </PreferenceScreen>

I want to show a custom LinearLayout that allows me to set some semi-complex preferences.

What is the best way to go about this?

Thanks, wTs

Was it helpful?

Solution

I've used a custom dialog box before for a preference. Is this sort of what you need? Here is an example from my open source app.

And here is the XML to add the preference to a PreferenceScreen.

<net.mandaria.tippytipper.preferences.DecimalPreference
                        android:key="exclude_tax"
                android:title="Tax Rate to Exclude"
                android:summary="The tax rate to exclude when calculating tip"
                android:dialogMessage="Tax Rate"
                android:defaultValue="0"
                android:dependency="enable_exclude_tax_rate"
                />

This will let you produce complex preferences in a DialogPreference (you might be able to swap this out if you don't need a Dialog, someone else will have to fill that in for you because I've never tried) that look like this:

alt text

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top