Note that there are some explanatory texts on larger screens.

plurals
  1. POActionBar Tabs with multiple fragments
    primarykey
    data
    text
    <p>I've been trying to update my app and get going with fragments, the action bar, and all the other UI features that I'm missing out on. I understand I can have multiple fragments in an activity, have different layouts based upon the device and all that good stuff but I'm struggling with getting some tab stuff the way I want. I understand how to add tabs, switching between them but how do I have more than one fragment in a tab? So for example I have essentially two screens I want the user to be able to switch back and forth from easily (why I want to use tabs). If I have two separate activities I can specify this in xml files and use setContentView using the layouts below</p> <p>tab1_layout.xml</p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" &gt; &lt;fragment android:name="com.example.tabrefactor.Fragment1" android:id="@+id/fragment_1" android:layout_height="wrap_content" android:layout_width="wrap_content"/&gt; &lt;fragment android:name="com.example.tabrefactor.Fragment2" android:id="@+id/fragment_2" android:layout_height="wrap_content" android:layout_width="wrap_content"/&gt; &lt;fragment android:name="com.example.tabrefactor.Fragment3" android:id="@+id/fragment_3" android:layout_height="wrap_content" android:layout_width="wrap_content"/&gt; &lt;/LinearLayout&gt; </code></pre> <p>tab2_layout.xml</p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" &gt; &lt;fragment android:name="com.example.tabrefactor.Fragment4" android:id="@+id/fragment_4" android:layout_height="wrap_content" android:layout_width="wrap_content"/&gt; &lt;/LinearLayout&gt; </code></pre> <p>I can convert the second layout to using tabs since its only contains one fragment but I'm not sure how get the first layout into a single tab. Is that something that's allowed? Thanks in advance,</p> <p>Jason Prenger </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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