AlertDialog style buttons for an Activity

后端 未结 2 1156
没有蜡笔的小新
没有蜡笔的小新 2021-01-05 04:49

I have an activity with a Save and Cancel button at the bottom.

In AlertDialog, the buttons are displayed inside a styled container view of some sort.

How c

2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-05 05:51

    I do some thing like this:

    LinearLayout dialogLayout = (LinearLayout) ((LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.dialog_addeditrecord, null);
    

    I then use the dialogLayout to call findViewById() to pull in the buttons and other views and setup OnClickListeners and such...

    then to show the dialog:

    builder = new AlertDialog.Builder(this);
    
    builder.setView(dialogLayout);
    
    builder.create().show();
    

提交回复
热议问题