对于活动AlertDialog式按键按键、AlertDialog

2023-09-06 10:50:13 作者:自渡

我有一个保存的活动和取消按钮的下方。

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

在AlertDialog,该按钮显示了某种风格的容器视图中。

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

我怎么能放弃我的活动同样外观的按钮?具体来说,我怎么能申请在AlertDialog按钮容器以说,在含有按钮我的活动一的LinearLayout的风格?

How could I give the buttons in my Activity that same appearance? Specifically, how could I apply the style of the button container view in the AlertDialog to say a LinearLayout in my Activity containing the buttons?

感谢

推荐答案

我做一些事情是这样的:

I do some thing like this:

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

我然后使用dialogLayout调用findViewById()拉中的按钮和其他视图和设置OnClickListeners和这样的...

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

然后显示的对话框:

builder = new AlertDialog.Builder(this);

builder.setView(dialogLayout);

builder.create().show();