Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to properly inflate a layout with a nested ViewFlipper?
    text
    copied!<p>I used to have a simple main.xml layout that had only 2 views flipped via ViewFlipper wrapper. It worked (still works) great, using the following code:</p> <pre><code>setContentView(R.layout.main); mTV1 = (TextView) findViewById(R.id.textview01); mTV2 = (TextView) findViewById(R.id.textview02); mViewFlipper = (ViewFlipper)findViewById(R.id.flipper01); </code></pre> <p>I now want to add 2 buttons on top of the original views, in a fashion similar to <a href="https://stackoverflow.com/a/6334526/1088880">this</a>:</p> <pre><code>&lt;LinearLayout android:id="@+id/linearLayout01" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;LinearLayout android:id="@+id/linearLayout02" android:layout_width="fill_parent" android:layout_height="wrap_content"&gt; &lt;Button android:id="@+id/button01" android:layout_height="wrap_content" android:text="Button 1" android:layout_width="0dip" android:layout_weight="1"&gt;&lt;/Button&gt; &lt;Button android:id="@+id/button02" android:layout_height="wrap_content" android:text="Button 2" android:layout_width="0dip" android:layout_weight="1"&gt;&lt;/Button&gt; &lt;/LinearLayout&gt; &lt;RelativeLayout android:id="@+id/relativeLayout01" android:layout_width="fill_parent" android:layout_height="0dp" android:layout_weight="1"&gt; &lt;ViewFlipper android:id="@+id/flipper01" android:layout_width="fill_parent" android:layout_height="fill_parent" &gt; &lt;TextView android:id="@+id/textview01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Text" /&gt; &lt;TextView android:id="@+id/textview02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Text2" /&gt; &lt;/ViewFlipper&gt; &lt;/RelativeLayout&gt; &lt;/LinearLayout&gt; </code></pre> <p>My problem is I intuitively modified the original code to by inserting a findViewById for the composite layout:</p> <pre><code>setContentView(R.layout.main); mCompositeLayout = (LinearLayout) findViewById(R.id.linearLayout02); mTV1 = (TextView) findViewById(R.id.textview01); mTV2 = (TextView) findViewById(R.id.textview02); mViewFlipper = (ViewFlipper)findViewById(R.id.flipper01); </code></pre> <p>But it displays exactly the same as before! As if I never added extra linearLayout02 containing the buttons.</p> <p>What am I missing? What am I doing wrong?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload