ericlee
ericlee

Reputation: 2753

programmatically set PreferenceScreen

I have a preferncescreen page for showing of data only and not saving it for setting

the code is as below

    <?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
    <PreferenceCategory android:title="Member Subscription Status">


        <PreferenceScreen
    android:title="Subscription Status"
    android:summary="Active">
</PreferenceScreen> 

        <PreferenceScreen
    android:title="Next Payment Date"
    android:summary="2012-06-21 18:00:00s">
</PreferenceScreen> 
        <PreferenceScreen
    android:title="Plan Type"
    android:summary="Family">
</PreferenceScreen> 
    </PreferenceCategory>


</PreferenceScreen>

Right now i am wondering how should i set the summary of the preferncescreen to show on the screen?

Upvotes: 2

Views: 3208

Answers (2)

ericlee
ericlee

Reputation: 2753

Found the solution. have to add a key first

android:key="Subscriptionstatus" 

then in activity

Preference pref = findPreference( "Subscriptionstatus" );
pref.setSummary("test");

Upvotes: 3

Darshan Rivka Whittle
Darshan Rivka Whittle

Reputation: 34031

You can get the Preference with findPreference() and then set the summary with setSummary().

Upvotes: 5

Related Questions