我的应用程序中有很多提醒对话框.这是默认布局,但我正在向对话框中添加正按钮和负按钮.因此,这些按钮的默认文本 colored颜色 为Android 5(绿色).我试着改变它,但没有成功.你知道怎么改变文字 colored颜色 吗?
我的自定义对话框:
public class MyCustomDialog extends AlertDialog.Builder {
public MyCustomDialog(Context context,String title,String message) {
super(context);
LayoutInflater inflater = (LayoutInflater) context.getSystemService( Context.LAYOUT_INFLATER_SERVICE );
View viewDialog = inflater.inflate(R.layout.dialog_simple, null, false);
TextView titleTextView = (TextView)viewDialog.findViewById(R.id.title);
titleTextView.setText(title);
TextView messageTextView = (TextView)viewDialog.findViewById(R.id.message);
messageTextView.setText(message);
this.setCancelable(false);
this.setView(viewDialog);
} }
创建对话框:
MyCustomDialog builder = new MyCustomDialog(getActivity(), "Try Again", errorMessage);
builder.setNegativeButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
...
}
}).show();
NegativeButton是默认的对话框按钮,采用Android 5棒棒糖中的默认绿色.
非常感谢