我在应用程序中有一个警报对话框,如下所示。
我希望标题和分隔标题的行 - 消息正文为橙色。我怎样才能做到这一点?我尝试的是使用自定义样式,如下所示。但这没有用。
<style name="AboutDialog" parent="@android:style/Theme.Dialog">
<item name="android:textColor">#E5492A</item>
</style>
我的警报对话框代码:
AlertDialog.Builder alertDialog = new AlertDialog.Builder( new ContextThemeWrapper(MainActivity.context, R.style.AboutDialog));
alertDialog.setTitle("Sample");
alertDialog.setMessage(R.string.rate_dialog_text);
alertDialog.setPositiveButton(R.string.rate_now_text,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
MainActivity.context.startActivity(new Intent(
Intent.ACTION_VIEW, Uri
.parse("market://details?id="
+ MainActivity.APP_PNAME)));
if (editor != null) {
editor.putBoolean("dontshowagain", true);
editor.commit();
}
dialog.dismiss();
}
});
alertDialog.setNeutralButton(R.string.remind_later_text,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
alertDialog.setNegativeButton(R.string.no_thanks_text,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
if (editor != null) {
editor.putBoolean("dontshowagain", true);
editor.commit();
}
dialog.dismiss();
}
});
return alertDialog.create();
}