How can I cancel the aftet closing settings dialog by pressing any button?
I decided to make my dialog class implement OnClickListener.
public class PassChangeDiglog extends DialogPreference implements
OnClickListener {
EditText oldpass, new_pass1, new_pass2;
public PassChangeDiglog(Context context, AttributeSet attrs) {
super(context, attrs);
setDialogLayoutResource(R.layout.pass_change_diglog);
setPositiveButtonText("OK");
setNegativeButtonText(R.string.Cancel);
}
@Override
protected void onBindDialogView(View view) {
setTitle(R.string.PassChanging);
oldpass = (EditText) view.findViewById(R.id.Dlg_old_pass);
new_pass1 = (EditText) view.findViewById(R.id.Dlg_NewPass1);
new_pass2 = (EditText) view.findViewById(R.id.Dlg_NewPass2);
super.onBindDialogView(view);
}
@Override
public void onClick(DialogInterface arg0, int arg1) {
switch (arg1) {
case DialogInterface.BUTTON_POSITIVE:
boolean needclose;
...
if (needclose)
arg0.dismiss();
else{
}
}
};
}
I tried to override the onDismiss method, but the dialog closes.
@Override
public void onDismiss(DialogInterface dialog) {
Log.d("MY","onDismiss");
}
source
share