How to create a Custom Dialog box in android?

后端 未结 22 2772
囚心锁ツ
囚心锁ツ 2020-11-21 07:06

I want to create a custom dialog box like below

\"enter

I have tried the foll

22条回答
  •  盖世英雄少女心
    2020-11-21 07:36

    Create alert Dialog layout something like this

     
     
        
    
    

    and Add below code on your Activity class

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    
        LayoutInflater inflate = LayoutInflater.from(this);
        alertView = inflate.inflate(R.layout.your_alert_layout, null);
        Button btn= (Button) alertView.findViewById(R.id.btn);
    
        showDialog();
      }
    
     public void showDialog(){
            Dialog alertDialog = new Dialog(RecognizeConceptsActivity.this);
            alertDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            alertDialog.setContentView(alertView);
            alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
            alertDialog.show();
        }
    

提交回复
热议问题