2012-02-12 3 views
0

Я пытаюсь изменить расположение/содержание xml линейного макета внутри прокрутки при нажатии кнопки. Я не хочу вызывать новое действие при нажатии кнопки или использовать setVisibility.Изменение макета 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

+0

Я планировал изменить его на картинку и сопроводительный текст, действуя как справочное приложение. – drew

ответ

0

Вы не говорите, почему вы не хотите использовать setVisivility(), но моя первая рекомендация будет заключаться в использовании FrameLayout и устанавливать различные взгляды видимыми или невидимыми, основанные на нажатие кнопки. Другая мысль - использовать ViewFlipper.

Смежные вопросы