How to create custom alert dialog in android?

前端 未结 9 1237
再見小時候
再見小時候 2020-12-09 10:36

I am developing a sample app.I am able to show alert on button click having some tittle and button .But now I want to show a pop up window having username (Label)

9条回答
  •  误落风尘
    2020-12-09 10:59

    custom_dialog.xml

    
    
    
    
        
    
        
        
    
             
    
            

    Need to inflate custom_dialog.xml

    final Dialog dialog = new Dialog(this);
    
    dialog.setContentView(R.layout.custom_dialog);
    dialog.setTitle("Custom Alert Dialog");
    
    final EditText editText = (EditText) dialog.findViewById(R.id.editText);
    Button btnSave          = (Button) dialog.findViewById(R.id.save);
    Button btnCancel        = (Button) dialog.findViewById(R.id.cancel);
    dialog.show();
    

提交回复
热议问题