阻止dialog消失的方法 (Android Platform)

来源:互联网 发布:软件授权工具 编辑:程序博客网 时间:2024/06/06 01:34

finalAlertDialog voipDialog;
voipDialog = builder.create();
voipDialog.setButton(DialogInterface.BUTTON_POSITIVE, "save", newDialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
String limitLengthStr = pstnLimitLengthEdittext.getText().toString().trim();
String prefixStr  =pstnPrefixEdittext.getText().toString().trim();
try{
Field field =voipDialog.getClass().getSuperclass().getDeclaredField("mShowing");
field.setAccessible(true);
if(notNull(limitLengthStr, prefixStr)){
if(isNumericLimitLength(limitLengthStr)){
if(isNumericPrefix(prefixStr)){
save("voip_limit_length",pstnLimitLengthEdittext.getText().toString());
save("voip_prefix",pstnPrefixEdittext.getText().toString());
field.set(dialog, true);
}else{
Toast.makeText(CallFeaturesSetting.this, R.string.toast_prefix_allow,Toast.LENGTH_LONG).show();
field.set(dialog, false);
return;
}
}else{
Toast.makeText(CallFeaturesSetting.this, R.string.toast_limitlength,Toast.LENGTH_LONG).show();
field.set(dialog, false);
return;
}
}else{
Toast.makeText(CallFeaturesSetting.this, R.string.toast_notnull,Toast.LENGTH_LONG).show();
field.set(dialog, false);
return;
}
}catch (Exception e) {
Log.i(LOG_TAG, "NoSuchFieldException");
}
}
});
voipDialog.show();

 

ORIETech - iPhone | Android Development Center