小编use*_*397的帖子

在空字符串输入上停用警报对话框正向按钮

我想只在用户输入不为空时才启用alertDialog肯定按钮,如果用户输入为空则禁用它,为了验证目的切换为王,用户输入不能为空.这是我的代码,即使我把一个字符串按钮没有激活.

buildInfos.setPositiveButton(android.R.string.ok, new OnClickListener() {

    @Override
    public void onClick(DialogInterface dialog, int which) {
        infosDesc = inputInfos.getText().toString();
        Log.i("DESC", infosDesc);
        drawBetween2LastPoints(getAlertColor(alertType), "title", infosDesc);
    }
});

AlertDialog buildInfosDialog = buildInfos.create();
buildInfosDialog.show();
if(infosDesc.isEmpty()){
    buildInfosDialog.getButton(Dialog.BUTTON_POSITIVE).setEnabled(false);
}
Run Code Online (Sandbox Code Playgroud)

java android validating android-alertdialog

2
推荐指数
1
解决办法
1846
查看次数

标签 统计

android ×1

android-alertdialog ×1

java ×1

validating ×1