i'm developing a custom DialogPreference.
When user clicks outside the dialog, it is cancelled and i need to avoid this.
I know that Dialog has method setCanceledOnTouchOutside(boolean cancel)
that is what i need but the DialogPreference not.
in onBindDialogView
i try:
getDialog().setCanceledOnTouchOutside(true);
but getDialog()
returns null
.
How can i do? Can someone help me?
This is my class:
public class UpdatePreference extends DialogPreference implements View.OnClickListener{
public UpdatePreference(Context context, AttributeSet attrs) {
super(context, attrs);
setPersistent(false);
setDialogLayoutResource(R.layout.update_dialog_layout);
setPositiveButtonText("");
setNegativeButtonText("");
}
@Override
protected void onBindDialogView(View view) {
super.onBindDialogView(view);
//init my components
}
@Override
protected void onDialogClosed(boolean positiveResult) {
super.onDialogClosed(positiveResult);
}
}