我正在尝试制作一个警告对话框,该对话框将向用户提出问题,并且消息中的某些文本将显示为红色。
这是我尝试过的:
AlertDialog.Builder dlgAlert = new AlertDialog.Builder(
this);
String You = "<font color='red'>you</font>?";
dlgAlert.setMessage("How are " + Html.fromHtml(You));
dlgAlert.setTitle("Mood");
dlgAlert.setPositiveButton("Good",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
dialog.dismiss();
}
});
dlgAlert.setNeutralButton("Okay",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
dialog.dismiss();
}
});
dlgAlert.setNegativeButton("Bad",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int which) {
dialog.dismiss();
}
});
dlgAlert.setCancelable(false);
dlgAlert.create().show();
它不会将“你”这个词变成红色。有任何想法吗?