繁体   English   中英

从在线文本文件中获取所有文本,并在TextView中全部显示

[英]Get all text from online text file and show it all in a TextView

我想从网页上获取所有文本,并将其保存到字符串数组/列表,然后在“视图/活动”中打印。

假设我有网址www.my.url/html.php ,在该页面上是这样的:

保罗

卡罗琳

史蒂夫”

...

...

现在,我希望将它们写在视图/活动中的相同位置。

我有这个简单的活动:

public class PlayerListActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_playerlist);
    }
}

而这个XML文件:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#121E26"
    tools:context="com.tominocz.stonequestapp.MainActivity"
    tools:ignore="MergeRootFrame,ContentDescription,HardcodedText,SpUsage,TextViewEdits,Deprecated,SmallSp" >

</FrameLayout>

就是我想要的样子。 您认为这可能吗?

如果是简单的html数据,则可以下载整个HTML。 也将TextView放在FrameLayout内并使用

textView.setText(Html.fromHtml(stringWithHtml));

方法文档在这里

请注意,并非所有HTML标记都受支持, 此处为非官方列表

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM