android - How to disable outside touching to hide DialogPreference -
i'm developing custom dialogpreference.
when user clicks outside dialog, cancelled , need avoid this.
i know dialog has method setcanceledontouchoutside(boolean cancel)
need dialogpreference not.
in onbinddialogview
try:
getdialog().setcanceledontouchoutside(true);
but getdialog()
returns null
.
how can do? can me?
this 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 components } @override protected void ondialogclosed(boolean positiveresult) { super.ondialogclosed(positiveresult); } }
you can access alerdialog.builder
before dialog shown. there can specify builder.setcancelable(false)
. in such way can achieve desire behavior.
@override protected void onpreparedialogbuilder(builder builder) { super.onpreparedialogbuilder(builder); builder.setcancelable(false); }
Comments
Post a Comment