Refresh or change the AlertDialog Message

后端 未结 4 425
攒了一身酷
攒了一身酷 2021-01-11 09:32

I create an AlertDialog

AlertDialog.Builder builder = new AlertDialog.Builder(this);
...
AlertDialog alert = builder.create();
alert.show();
<
4条回答
  •  北海茫月
    2021-01-11 10:02

    Set OnClickListener out of main setter like this:

    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity())
                            .setTitle(getResources().getString(R.string.dialog_title))
                            .setMessage("Waiting ...")
                            .setNeutralButton(R.string.check, null);
    
    AlertDialog alertDialog = alertDialogBuilder.create();
    alertDialog.show();
    
    Button b_neutral = alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL);
    b_neutral.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            TextView tv_message = (TextView) alertDialog.findViewById(android.R.id.message);
                            tv_message.setText("Works ...");
        }
    });
    

提交回复
热议问题