我在我的应用程序中有许多警报对话框。它是默认布局,但我正在向对话框添加积极和消极按钮。因此,按钮获得Android 5的默认文本颜色(绿色)。我尝试过更改它,但没有成功。有什么办法可以更改那个文本颜色吗?
我的自定义对话框:
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 Lollipop 中获取默认的绿色。
非常感谢