title: Android: Display two ListViews via Fragments using Fragmenttransaction
body: <p>For my app, I'm trying to show a list, and as soon as this list ends, the second one shall begin. The Lists are being displayed using a ListAdapter, which again is part of a fragment. Everything works very well, the lists appear correctly, but I can't figure out a way to put one list under the other. I thought this shouldn't be all too hard. 
  Summary:</p>
  
  <p><strong>What I have:</strong>
  A <code>FragmentPagerAdapter</code> with 3 Fragments
  Two Fragments, which contain one ListView each</p>
  
  <p><strong>My searches:</strong>
  Apart from multiple searches on this site, this guy came closest to what I'm seeking:
  This guy here <a href="https://stackoverflow.com/questions/18968972/commiting-fragmenttransaction-in-1-tab-of-a-fragmentpageradapter">Fragmenttransaction in 1 tab of a Fragmentpageradapter</a>has had the same problem, but it wasn't satisfyingly answered, so I thought I can make a valid question here.</p>
  
  <p><strong>My question:</strong>
  How can I place two <code>ListViews</code> in one Fragment? The big deal is that for example if the first ListView is bigger than the screen, I don't want the second ListView to show up before the first is completely scrolled down. </p>
  
  <p><strong>Current output:</strong>
  Currently, both <code>ListViews</code> are in the same position, meaning that one <code>ListView</code> is on top of the other, making both unreadable</p>
  
  <p>I thought that I can maybe use a specified layout for the <code>FragmentTransaction</code>. But I just can't figure out how.</p>
  
  <p><strong>This is the Fragment where I combine my top and bottom <code>ListViews</code></strong></p>
  
  <pre><code>public class LeaguePageTransactionsAdapter extends Fragment{
  Global global_var;
  ListView list, list_flat;
  List &lt;League&gt; leagues = null, leaguesFlat = null;
  ListAdapter adapter = null, adapter_flat = null;
  View rootView;
  FragmentTransaction fragmentTransaction;
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
      rootView = inflater.inflate(R.layout.league_page, container, false);
      fragmentTransaction = getFragmentManager().beginTransaction();
      fragmentTransaction.add(rootView.getId(), new LeaguePageTop(), "TopFragment");  
      fragmentTransaction.add(rootView.getId(), new LeaguePageBottom(), "BottomFragment");
      fragmentTransaction.commit();
      return rootView;
     }
  
  @Override
  public void onViewCreated(View view, Bundle savedInstanceState) {
      // TODO Auto-generated method stub
      super.onViewCreated(view, savedInstanceState);
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p><strong>This is corresponding the xml layout file.</strong></p>
  
  <pre><code>&lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/fragment_container"
  android:layout_width="match_parent"
  android:layout_height="match_parent" /&gt;
  </code></pre>
  
  <p><strong>This is one of my two <code>ListViews</code></strong></p>
  
  <pre><code>public class LeaguePageTop extends Fragment{
  ListView list;
  List &lt;League&gt; leagues = null;
  ListAdapter adapter = null;
  View rootView;
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
      rootView = inflater.inflate(R.layout.league_page_top, container, false);
      return rootView;
     }
  
  @Override
  public void onViewCreated(View view, Bundle savedInstanceState) {
      // TODO Auto-generated method stub
      super.onViewCreated(view, savedInstanceState);
      list = (ListView) rootView.findViewById(R.id.listView1);
  
      try {
          leagues = Leagues_Parser.parse(getActivity().getAssets().open("league_raw.xml"), 0);
  
      } catch (IOException e) {
          e.printStackTrace();
      }
      adapter = new LeagueAdapter (getActivity(), R.layout.list_row, leagues);
  
      list.setAdapter(adapter);
  
      list.setOnItemClickListener(new OnItemClickListener()
         {
  
          @Override
          public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int arg2,
                  long arg3) {
              // TODO Auto-generated method stub
              Global.mViewPager.setCurrentItem(1, true);
          }
         });
  }
  </code></pre>
  
  <p>}</p>
  
  <p><strong>This is the corresponding xml file</strong></p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &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;ListView
          android:id="@+id/listView1"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"&gt;
      &lt;/ListView&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Thank you very much for reading and thinking about it!</p>