我Html.fromHtml用来查看html TextView.
Spanned result = Html.fromHtml(mNews.getTitle());
...
...
mNewsTitle.setText(result);
Run Code Online (Sandbox Code Playgroud)
但Html.fromHtml现在已经在Android N +中弃用了
我/我如何找到新的方法?
我想在 AlertDialog 中以粗体显示消息文本的一部分。
我试过:
添加<b> </b> tag在strings.xml,但没有积极的。
我也用过 Html.fromHtml("<b>"+getString(R.string.ittformulanote)+"</b>")
我也去过stackoverflow.com但没有积极的结果。
在我的代码下面:
showDialog(getActivity(),"Sample",Html.fromHtml("<b>"+getString(R.string.ittformulanote)+"</b>")+"\n\n"+));
public static void showDialog(Context mContext, String Title,
String Description) {
final AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
dialog.setTitle(Title);
// dialog.setMessage((Html.fromHtml("<b>"+Description+"</b>")));
dialog.setMessage(Description);
dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
// TODO Auto-generated method stub
}
});
//
AlertDialog alert=dialog.create();
// dialog.show();
alert.show();
}
Run Code Online (Sandbox Code Playgroud)