I would like to be able launch a 2nd Preference screen from my PreferenceActivity. And in the 2nd Preference screen I\'d like to use a predefined layout from xml. So, I ha
One solution would be to extend a DialogPreference which allows the setting of a custom layout for the preference dialog. This way you have a preference listed and when you tap it, you get a dialog with your custom settings UI.
And the class
class MyPreference extends DialogPreference {
// along with constructors, you will want to override
@Override
protected void onBindDialogView(View view) {
super.onBindDialogView(view);
// view is your layout expanded and added to the dialog
// find and hang on to your views here, add click listeners etc
// basically things you would do in onCreate
mTextView = (TextView)view.findViewById(R.Id.mytextview);
}
@Override
protected void onDialogClosed(boolean positiveResult) {
super.onDialogClosed(positiveResult);
if (positiveResult) {
// deal with persisting your values here
}
}
}
Obviously there are some other details, but this is the basic idea.