getActivity() where it is defined?

前端 未结 11 1981
温柔的废话
温柔的废话 2020-12-13 10:19

I\'m very new to android and I\'m following this example.

The code says we need to do these steps to get an dialog box:

AlertDialog.Builder builder =         


        
11条回答
  •  余生分开走
    2020-12-13 10:37

    // 1. Instantiate an AlertDialog.Builder with its constructor

    AlertDialog.Builder builder = new AlertDialog.Builder(yourActivityName.this);
    

    // 2. Chain together various setter methods to set the dialog characteristics

    builder.setMessage(R.string.dialog_message).setTitle(R.string.dialog_title);
    

    // 3. Get the AlertDialog from create()

    AlertDialog dialog = builder.create();
    

    // 4. Show the AlertDialog

    dialog.show();
    

提交回复
热议问题