android : html list view not working in the string. xml 文件

标签 android textview

我必须在 fragment 中插入一个列表(不是 android ListView ,而是简单的 html 列表)。布局文件“about.xml”页面只有一个 TextView ,该 TextView 正在动态集群,从 string.xml 文件获取数据。 string.xml 中的声明如下:

<string name="AboutThisApp"><![CDATA[

<div>
    <p>here is the list of functions: </p>
</div>

<ul>
    <li> Sportsmanship</li>
    <li> Participation</li>
    <li> Safety/Risk Minimization</li>
    <li> Sound Traditions of the Sport</li>
    <li> Support for USA Footvall\'s Mission</li>
    <li> Balance Between Offense and Defence</li>
</ul>

]]></string>

此数据正在布局文件夹中的 TextView 中访问,如下所示(文件为“about.xml”):

<TextView
            android:id="@+id/textViewAbout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingBottom="20dp"
            android:paddingLeft="10dp"
            android:paddingRight="16dp"
            android:textColor="@color/white"
            android:textSize="16dp"
            customText:textcustomFont="fonts/montserrat-r.ttf" />

访问java文件中数据的对象如下:

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.usafootball.rulesapp.R;
import com.usafootball.rulesapp.customfont.TextViewPlus;

public class AboutThisAppFragment extends Fragment {

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {

        View mView = inflater.inflate(R.layout.about,
                container, false);
        TextViewPlus textViewPlus = (TextViewPlus) mView.findViewById(R.id.textViewAboutUSAF);
        textViewPlus.setText(Html.fromHtml(getString(R.string.AboutThisApp)));

        return mView;
    }

}

为了更清楚地显示数据,但它以段落 NOT LIST 的形式出现。任何建议如何执行此操作...

最佳答案

据我所知<ul> , <li> TextView 不支持标签,这就是它不起作用的原因。请参阅此处支持的标签列表:HTML Tags Supported By TextView

关于android : html list view not working in the string. xml 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18831953/

相关文章:

java - 如何在主 Activity 中调用myCustomAdapter的公共(public)方法?

java - Google Maps Api V2 无法执行 dex : Java heap space. 正在刷新外部存档(已阻止)

android - Jelly Bean 令人困惑的 LogCat

Android TextView 智能引号

java - 使用 Jackson Object Mapper 将 Map 转换为 Java 对象非常慢

java - 在AlertDialog的Onclick上调用另一个类的方法

android - 阻止 TextView 截断整个单词

android - 删除 TextView 中不需要的行间距

android - 几个 Textviews 下的按钮

android - 如何在textview文本中写下标和上标?