Backspace&输入按钮不适用于警告对话框

时间:2018-05-12 15:36:12

标签: android keyboard alertdialog

当我尝试删除或输入alertdialog中的编辑文本时,它不起作用,我的代码会出现什么问题?请帮我解决这个问题.. 这是我的alertdialog代码:

private void showFormBioData(){
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    View dialogView = getLayoutInflater().inflate(R.layout.activity_bio_data,null);
    builder.setView(dialogView);
    builder.setCancelable(false);
    Button submit = dialogView.findViewById(R.id.btnSubmit);
    final TextView userName = dialogView.findViewById(R.id.bioName);
    final TextView shopName = dialogView.findViewById(R.id.bioToko);
    final TextView address = dialogView.findViewById(R.id.bioAlamat);
    final TextView email = dialogView.findViewById(R.id.bioEmail);
    final TextView telp = dialogView.findViewById(R.id.bioNope);

    final AlertDialog dialog = builder.create();
    dialog.setOnKeyListener(new DialogInterface.OnKeyListener() {
        @Override
        public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_BACK){
                dialog.dismiss();
                finish();
            }
            return true;
        }
    });
    dialog.show();

    submit.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

                pdSubmit.show();
                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        Toast.makeText(MainActivity.this, "Upload to firebase", Toast.LENGTH_SHORT).show();
                     pdSubmit.dismiss();

                }
            },2000);
        }
    });
}

0 个答案:

没有答案