相关疑难解决方法(0)

Html.fromHtml在Android N中已弃用

Html.fromHtml用来查看html TextView.

Spanned result = Html.fromHtml(mNews.getTitle());
...
...
mNewsTitle.setText(result);
Run Code Online (Sandbox Code Playgroud)

Html.fromHtml现在已经在Android N +中弃用了

我/我如何找到新的方法?

android deprecated android-7.0-nougat

266
推荐指数
10
解决办法
13万
查看次数

在 AlertDialog 中设置粗体文本

我想在 AlertDialog 中以粗体显示消息文本的一部分。

我试过:

添加<b> </b> tagstrings.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)

android android-alertdialog

5
推荐指数
2
解决办法
7829
查看次数