Ran*_*nco 0 user-interface android
我有一个自定义DialogFragment(支持库).我将布局设置为@ color/GhostWhite,问题是,我找不到一种方法来设置相同颜色的正/负按钮.
这就是我设置按钮的方式:
builder.setView(view)
// Add action buttons
.setPositiveButton("Shout!", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
//publishStory(/*shoutText.getText().toString()"woww");
mListener.onDialogPositiveClick(WagDialogFragment.this);
}
})
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
}
});
return builder.create();
Run Code Online (Sandbox Code Playgroud)
您可以getButton使用DialogInterface.BUTTON_POSITIVE和DialogInterface.BUTTON_NEGATIVE参数来更改两个按钮的颜色:
Button okButton = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE);
// set OK button color here
okButton.setBackgroundColor(R.color.GhostWhite);
Button noButton = alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE);
// set NO button color here
noButton.setBackgroundColor(R.color.GhostWhite);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4222 次 |
| 最近记录: |