Reputation: 14625
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 presses "Manage Favorits.
This is the custom layout i have in mind:
Is it possible to use custom layout on "sub-preference-screens"?
Thanks!
Upvotes: 1
Views: 3653
Reputation: 60184
Yes, you can launch a separate activity
using intent
.
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceScreen android:title="@string/your_title"
android:summary="@string/your_string">
<intent android: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.
Upvotes: 2