我试图在按下按钮时更改 ScrollView 内线性布局的 xml 布局/内容。我不想在按下按钮或使用 setVisibility 时调用新的 Activity。
到目前为止,屏幕的 10% 被保留为包含 2 个按钮的导航栏。下面是一个 ScrollView ,内部有线性布局,里面有内容。我希望当按下“下一步”按钮时,线性布局中的内容会发生变化。 这是一个引用应用程序,旨在容纳 50 多页信息。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:orientation="horizontal"
android:layout_weight="10">
<Button
android:id="@+id/buttonPrevious"
android:layout_width="0dip"
android:layout_height="fill_parent"
android:text="Previous"
android:layout_weight="30"/>
<Spinner
android:id="@+id/select"
android:layout_width="0dip"
android:layout_height="fill_parent" android:layout_weight="50"/>
<Button
android:id="@+id/buttonNext"
android:layout_width="0dip"
android:layout_height="fill_parent"
android:text="Next" android:layout_weight="20"/>
</LinearLayout>
<ScrollView
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="80">
<LinearLayout
android:id="@+id/linearLayout3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="top|center"
android:text="Header"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="According to the Oxford English Dictionary, hello is an alteration of hallo, hollo,[3] which came from Old High German "halâ, holâ, emphatic imperative of halôn, holôn to fetch, used especially in hailing a ferryman."[4] It also connects the development of hello to the influence of an earlier form, holla, whose origin is in the French holà (roughly, 'whoa there!', from French là 'there').[5] As in addition to hello, hallo and hollo, hullo and (rarely) hillo also exist as variants or related words, the word can be spelt using any of all five vowels.Hello is alternatively thought to come from the word hallo (1840) via hollo (also holla, holloa, halloo, halloa).[9] The definition of hollo is to shout or an exclamation originally shouted in a hunt when the quarry was spotted:[9] Fowler's has it that "hallo" is first recorded "as a shout to call attention" in 1864.[16]" android:textSize="20dip"/>
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:orientation="vertical"
android:layout_weight="10">
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TestAd"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
</LinearLayout>
最佳答案
您可以使用FragmentPager
关于java - 按下按钮时更改 XML 布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9245198/