Note that there are some explanatory texts on larger screens.

plurals
  1. POfragment shows only one list
    text
    copied!<p>I try to show two lists from my fragment. When I show the first one (array1), it's ok. But when I add the second one it just replaces the first and I see only the second list (array 2). Here is my code, could please tell me what's the problem here?</p> <p>Here is my fragment file:</p> <pre><code>public class ToFragment extends ListFragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { String[] array1 = { "listitem1", "listitem2" }; String[] array2 = { "listitem1" }; ArrayAdapter&lt;String&gt; adapter1 = new ArrayAdapter&lt;String&gt;(inflater.getContext(), R.layout.trainlist, R.id.traintextviewid); adapter1.addAll(array1); setListAdapter(adapter1); ArrayAdapter&lt;String&gt; adapter2 = new ArrayAdapter&lt;String&gt;(inflater.getContext(), R.layout.trainlist, R.id.timetextviewid); adapter2.addAll(array2); setListAdapter(adapter2); return super.onCreateView(inflater, container, savedInstanceState); } </code></pre> <p>Here is tofragment.xml:</p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/fragment_container" android:baselineAligned="false" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_gravity="center" android:orientation="horizontal" &gt; &lt;ListView android:id="@+id/trainlist" android:layout_width="250dp" android:layout_height="wrap_content" &gt; &lt;/ListView&gt; &lt;ListView android:id="@+id/timelist" android:layout_width="48dp" android:layout_height="wrap_content"&gt; &lt;/ListView&gt; &lt;/LinearLayout&gt; </code></pre> <p>And trainlist.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="horizontal" &gt; &lt;TextView android:id="@+id/traintextviewid" android:textIsSelectable="true" android:layout_width="250dp" android:layout_height="48dp"/&gt; &lt;TextView android:id="@+id/timetextviewid" android:layout_width="48dp" android:layout_height="48dp" android:textIsSelectable="true" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>I want it to look like two lists, second is low-width. Please tell me what to do!</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