I have one activity in which I need to display two lists that fetch from two sqlite tables. for every list, I am writing a customCursorAdapter
Can anyone guide me to a useful example, or just how to make such a scenario possible ? Thank you.
Here is the layout that will contain two lists-
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="2" >
<ListView
android:id="@+id/lvOne"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" >
</ListView>
<ListView
android:id="@+id/lvTwo"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" >
</ListView>
</LinearLayout>
And your class which should extend the Activity class (Not ListActivity class) should be similar to this--
public class TwoListActivity extends Activity {
ListView lvOne ;
ListView lvTwo ;
MyAdapter adapter ; // Initialise your adapter
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_two_list);
lvOne = (ListView) findViewById(R.id.lvOne);
lvTwo = (ListView) findViewById(R.id.lvTwo);
lvOne.setAdapter(/*** Create and set your adapter****/);
lvTwo.setAdapter(/*** Create and set your adapter****/);
}
Hope this helps.