final AlertDialog voipDialog;
voipDialog = builder.create();
voipDialog.setButton(DialogInterface.BUTTON_POSITIVE, "save", new DialogInterface.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();
VoIP设置与保存参数
本文详细介绍了如何在VoIP应用中创建对话框并设置按钮,实现限制长度和前缀的保存功能。包括验证输入的有效性和展示错误提示。
1171

被折叠的 条评论
为什么被折叠?



