DialogFragment按钮外观

时间:2018-03-12 11:09:50

标签: android android-fragments dialog

我的对话问题需要一些帮助。我从自定义视图创建了dialogFragment,并设置了正/负按钮,如下所示:

  @Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    LayoutInflater inflater = getActivity().getLayoutInflater();
    builder.setView(inflater.inflate(R.layout.add_product, null)).
            setPositiveButton(R.string.add, new DialogListener(getActivity(), true)).
            setNegativeButton(R.string.cancel, new DialogListener(getActivity(), false));
    return builder.create();
}

我得到了什么:enter image description here 这是一个问题:如何获得样本中显示的按钮: enter image description here

我更喜欢那种按钮的样式,在这种情况下如何使用它。

1 个答案:

答案 0 :(得分:-1)

builder.setPositiveButton("Sighin", new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog, int id) {
        dialog.dismiss();
    }
});

builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog, int id) {
        dialog.dismiss();
    }
});
AlertDialog alertDialog = builder.create();
alertDialog.show();
break;