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

Refresh

December 2018

Views

83 time

2

I want to get all the text from a webpage and save it to a String array/list and then print it in a View/Activity..

Let's say I have URL www.my.url/html.php and on that page is this:

Paul

Caroline

Steve'

...

...

And now I want them to be written in the same position in an View/Activity.

I have this simple Activity:

public class PlayerListActivity extends Activity {

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

And this XML file:

<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>

This is what I want it to look like. Do you think this is possible?

1 answers

0

если это просто HTML данные , которые вы можете загрузить весь HTML. также положить TextViewвнутрь FrameLayout и использования

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

док метода здесь

обратите внимание , что не все HTML - теги поддерживаются, неофициальный список ЗДЕСЬ