Skip to content Skip to sidebar Skip to footer

Custom Preferencescreen In Preferencescreen

I have a standard preference page in my app. But from this preference page i want the user to be able to navigate to an other PreferenceScreen with a custom layout, when user press

Solution 1:

Yes, you can launch a separate activity using intent.

<PreferenceScreenxmlns:android="http://schemas.android.com/apk/res/android"><PreferenceScreenandroid:title="@string/your_title"android:summary="@string/your_string"><intentandroid:targetClass="your.package.YourClass"android:targetPackage="your.package" /></PreferenceScreen></PreferenceScreen>

As long as you want to specify your own layout you would need to extend Preference class.

Use setLayoutResource() to define your layout in your constructor. Constructor needs to be

public YourClass(Context context, AttributeSet attrs) {
        super(context, attrs);
        setLayoutResource(R.layout.your_custom_layout);
    }

You can also check this.

Post a Comment for "Custom Preferencescreen In Preferencescreen"