Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here is a decent solution to more than one ListView within the same Activity. First the all-important layout file (copied from <a href="https://stackoverflow.com/questions/3968171/android-split-the-screen-in-2-equals-parts-with-2-listviews">ANDROID : split the screen in 2 equals parts with 2 listviews </a>, good job!). Note that the ListViews are embedded in their own LinearLayouts, which are each equally weighted.</p> <pre><code>&lt;LinearLayout android:layout_weight="1" android:layout_height="fill_parent" android:layout_width="fill_parent"&gt; &lt;ListView android:id="@+id/list1" android:layout_height="fill_parent" android:layout_width="fill_parent"&gt; &lt;/ListView&gt; &lt;/LinearLayout&gt; &lt;LinearLayout android:layout_weight="1" android:layout_height="fill_parent" android:layout_width="fill_parent"&gt; &lt;ListView android:id="@+id/list2" android:layout_height="fill_parent" android:layout_width="fill_parent"&gt; &lt;/ListView&gt; &lt;/LinearLayout&gt; </code></pre> <p></p> <pre><code>// Start java Code (you can figure out the imports) public class AnActivity extends Activity { private ListView lv1 = null; private ListView lv2 = null; private String s1[] = {"a", "b", "c", "d", "e", "f"}; private String s2[] = {"r", "s", "t", "u", "v", "w", "x"}; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // Get UI references. // lv1 = (ListView) findViewById (R.id.list1); lv2 = (ListView) findViewById (R.id.list2); lv1.setAdapter(new ArrayAdapter&lt;String&gt; (this, android.R.layout.simple_list_item_1, s1)); lv2.setAdapter(new ArrayAdapter&lt;String&gt; (this, android.R.layout.simple_list_item_1, s2)); } // onCreate() } // class </code></pre> <p>Sorry if there are any typos. I'm editing right here in the window, not in eclipse. Good luck!</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