【问题标题】:How to use HTML in TextView with the string如何在 TextView 中使用带有字符串的 HTML
【发布时间】:2019-05-11 05:04:37
【问题描述】:

我为学生的医疗目录使用脚本,我是 android 的初学者。

我使用 Firebase 数据库来存储应用的数据。所以我写了像

这样的html标签
<b>Anatomy</b>

但应用程序没有格式化 html 标签

private void initView() {
    setContentView(R.layout.activity_word_detail);
    tvWord = findViewById(R.id.textview_word);
    tvWordMeaning = findViewById(R.id.textview_word_meaning);
    tvType = findViewById(R.id.textview_word_type);
    tvSynonym = findViewById(R.id.textview_synonym);
    tvAntonym = findViewById(R.id.textview_antonym);
    tvExample = findViewById(R.id.textview_example);
    voiceIcon = findViewById(R.id.voice_icon_detail);
    favorite=findViewById(R.id.favorite_icon_detail);
    unFavorite=findViewById(R.id.unfavorite_icon_detail);

}
<TextView
                 android:id="@+id/textview_example"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_marginRight="32dp"
                 android:textColor="@color/blue"
                 android:text="@string/example_text"
                 android:textSize="14sp"
                 android:paddingBottom="10dp"
                 android:autoLink="web"
                 android:linksClickable="true"
                 />

id 为 textview_example 的 TextView 以 html 格式显示结果,我不知道该怎么做

【问题讨论】:

标签: android html textview


【解决方案1】:

试试这个

tvExample.setText(Html.fromHtml("<p> text here</p>"));

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-05-31
    • 1970-01-01
    • 1970-01-01
    • 2019-08-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多