Android: 添加一个很长的TextView到一个Fragment

Android: Add a very long TextView to a Fragment

我正在尝试在片段中添加很长的文本(Glgamesh 的史诗)。

我的 xml 版本:

<LinearLayout.LayoutParams xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    tools:context=".viewOne">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/epica"
        android:text=" **I WILL INSERT HERE THE WHOLE TEXT?**" />

</LinearLayout.LayoutParams>

还有 java 部分是什么? 我必须重写setText中的内容吗?我可以仅通过 ID 召回它吗?

    @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.dynamic_linearlayout);

    LinearLayout linearLayout = (LinearLayout) findViewById(R.id.epica);

TextView textView = new TextView(this);
    textView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT));

嘿,谢谢!

如果你想把 APP 做成一本有书页的书,你不能这样做。您必须创建一个数据库来存储每个页面的内容。然后您可以在用户点击按钮时逐页加载到文本视图。

您提供的 java 代码可以更改如下。

    @Override
    protected void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
     setContentView(R.layout.dynamic_linearlayout);

     TextView epica = (Textview) findViewById(R.id.epica);

     epica.setText("Some text here");