android - How do i display a ListView with a header below another ListView all in Tab1 of TabHost? -
i'm trying put listview below listview in first tab using tabhost.
the reason want because want divide list of trading cards type guess creating sections or whatever.
here .xml:
<?xml version="1.0" encoding="utf-8"?> <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:orientation="vertical" > <textview android:id="@+id/banlistdate" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="#000000" android:text="banlist date: march, 2013" android:textappearance="?android:attr/textappearancelarge" android:textcolor="#ffffff" /> <tabhost android:id="@+id/tabhost" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_below="@id/banlistdate" > <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <tabwidget android:id="@android:id/tabs" android:layout_width="match_parent" android:layout_height="wrap_content" > </tabwidget> <framelayout android:id="@android:id/tabcontent" android:layout_width="match_parent" android:layout_height="match_parent" > <linearlayout android:id="@+id/tab1" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" > <listview android:id="@+id/flv1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#ff8b53" tools:listheader="@layout/banlist_header_effectmonsters" > </listview> <listview android:id="@+id/flv2" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#a086b7" tools:listheader="@layout/banlist_header_fusionmonsters" > </listview> </linearlayout> <linearlayout android:id="@+id/tab2" android:layout_width="match_parent" android:layout_height="match_parent" > <listview android:id="@+id/flv3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" > </listview> </linearlayout> <linearlayout android:id="@+id/tab3" android:layout_width="match_parent" android:layout_height="match_parent" > <listview android:id="@+id/listview1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" > </listview> </linearlayout> </framelayout> </linearlayout> </tabhost> </linearlayout> here main java file start tabs , setup listviews:
package cybertech.productions.yugiohlibrary; import java.util.arraylist; import java.util.arrays; import android.app.activity; import android.os.bundle; import android.view.view; import android.view.view.onclicklistener; import android.widget.arrayadapter; import android.widget.listview; import android.widget.tabhost; import android.widget.tabhost.tabspec; import android.widget.textview; public class banlist extends activity implements onclicklistener { tabhost th; initializers initialmngr; arrayadapter<string> listadapter; listview forbiddenemlistview, forbiddenflistview; @override protected void oncreate(bundle savedinstancestate) { // todo auto-generated method stub super.oncreate(savedinstancestate); setcontentview(r.layout.banlist); th = (tabhost) findviewbyid(r.id.tabhost); th.setup(); tabspec specs = th.newtabspec("tag1"); specs.setcontent(r.id.tab1); specs.setindicator("forbidden"); th.addtab(specs); specs = th.newtabspec("tag2"); specs.setcontent(r.id.tab2); specs.setindicator("semi-limited"); th.addtab(specs); specs = th.newtabspec("tag3"); specs.setcontent(r.id.tab3); specs.setindicator("limited"); th.addtab(specs); th.setcurrenttab(0); // #begin: tab 1 listviews //setup "forbidden" listview(s); // listview 1: effect monsters forbiddenemlistview = (listview) findviewbyid(r.id.flv1); arraylist<string> forbiddenemlist = new arraylist<string>(); forbiddenemlist.addall(arrays.aslist(initialmngr.forbiddenem)); listadapter = new arrayadapter<string>(this, android.r.layout.simple_list_item_1, forbiddenemlist); view effectmon_header = view.inflate(this, r.layout.banlist_header_effectmonsters, null); forbiddenemlistview.addheaderview(effectmon_header); forbiddenemlistview.setadapter(listadapter); // listview 2: fusion monsters forbiddenflistview = (listview) findviewbyid(r.id.flv2); arraylist<string> forbiddenflist = new arraylist<string>(); forbiddenflist.addall(arrays.aslist(initialmngr.forbiddenf)); listadapter = new arrayadapter<string>(this, android.r.layout.simple_list_item_1, forbiddenflist); view fusion_header = view.inflate(this, r.layout.banlist_header_fusionmonsters, null); forbiddenflistview.addheaderview(fusion_header); forbiddenflistview.setadapter(listadapter); // #end: tab 1 listviews } @override public void onclick(view arg0) { // todo auto-generated method stub } } thanks help.
you want use expandablelistview. use group views label different categories or sections. since using arrays lists, simpleexpandablelistadapter should fit bill nicely.
Comments
Post a Comment