2012-02-12 65 views
0

我试图在按下按钮时更改滚动视图内部的线性布局的xml布局/内容。当按下按钮或使用setVisibility时,我不想调用新的Activity。当按下按钮时更改XML布局

到目前为止,屏幕的10%被预留为一个导航栏外壳2个按钮。下面是一个内部呈线性布局的滚动视图,其内部将是内容。当按下“下一个”按钮时,我希望在线性布局内更改内容。 这是一个参考应用程序,旨在保存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> 
+0

那么你希望内容改变到什么程度?你没有解释得很好。 – Squonk 2012-02-12 01:13:46

+0

我打算将其更改为图片和相关文本,充当参考应用程序。 – drew 2012-02-12 02:54:46

回答

0

你不说为什么你不希望使用setVisivility(),但我的第一个建议是使用基于可见或不可见一个FrameLayout并设置不同的看法按钮按下。另一个想法是使用ViewFlipper