java - 按下按钮时更改 XML 布局

标签 java android xml eclipse

我试图在按下按钮时更改 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 &quot;halâ, holâ, emphatic imperative of halôn, holôn to fetch, used especially in hailing a ferryman.&quot;[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 &quot;hallo&quot; is first recorded &quot;as a shout to call attention&quot; 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/

相关文章:

xml - 大学类(class)的 XML 编码

xml - 命名空间声明问题

java - 如何从 Excel 文件中逐行读取值并将其放入 Map 中?

java - 在 Java 中将编译时常量 int 转换为编译时常量 String

android - minSdkVersion 低于设备 API 版本的 INSTALL_FAILED_OLDER_SDK

android - 导航 header 初始化变量上的空指针异常

ruby-on-rails - Rails XML 解析

java - 从 GWT 和 eclipse 开始

java - 是否可以从 Java 程序内部捕获 Windows 弹出消息框?

android - 我可以在一个 Drawable XML 中使用多个渐变吗?