我正在嘗試在片段中添加一個(gè)很長的文本(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 中的內(nèi)容嗎?憑身份證能回憶起來嗎? @Overrideprotected 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));嘿,謝謝!
1 回答

森欄
TA貢獻(xiàn)1810條經(jīng)驗(yàn) 獲得超5個(gè)贊
如果你試圖讓 APP 像一本有頁面的書,你不能這樣做。您必須創(chuàng)建一個(gè)數(shù)據(jù)庫來存儲每個(gè)頁面的內(nèi)容。然后,當(dāng)用戶點(diǎn)擊按鈕時(shí),您可以將一頁一頁地加載到文本視圖中。
您提供的 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");
添加回答
舉報(bào)
0/150
提交
取消