android - Same custom list on both tabs using TabHost, but different data -


i have used tabhost display 2 tabs. on 1 of tabs, there custom list. don't know how display same custom list on other tab, different data. have placed listview in other tab too. after that? need write whole code again? or need override ontabchangedlistener method. xml:

<tabhost     android:id="@+id/tabhost"     android:layout_width="match_parent"     android:layout_height="match_parent" >      <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" >              <relativelayout                 android:id="@+id/tab1"                 android:layout_width="match_parent"                 android:layout_height="match_parent" >                  <listview                     android:id="@android:id/list"                     android:layout_width="match_parent"                     android:layout_height="wrap_content"                     android:layout_centerhorizontal="true" >                 </listview>              </relativelayout>              <relativelayout                 android:id="@+id/tab2"                 android:layout_width="match_parent"                 android:layout_height="match_parent" >                  <listview                     android:id="@android:id/list"                     android:layout_width="match_parent"                     android:layout_height="wrap_content"                     android:layout_centerhorizontal="true" >                 </listview>              </relativelayout>         </framelayout>     </linearlayout> </tabhost> 

the code:

public class contacts extends listactivity { private tabhost thcont; private string tab_1_tag = "tag1"; private string tab_2_tag = "tag2"; private int[] imagesid1 = {r.drawable.praneel, r.drawable.saakshi, r.drawable.arjun, r.drawable.rishi, r.drawable.nisarg, r.drawable.ankit, r.drawable.sharad};  @override protected void oncreate(bundle savedinstancestate)  {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_contacts2);     thcont = (tabhost) findviewbyid(r.id.tabhost);     thcont.setup();     tabspec specs;      // tab1     specs = thcont.newtabspec(tab_1_tag);     specs.setcontent(r.id.tab1);     specs.setindicator("managing team");     thcont.addtab(specs);      // tab 2     specs = thcont.newtabspec(tab_2_tag);     specs.setcontent(r.id.tab2);     specs.setindicator("heads");     thcont.addtab(specs);      setlistadapter(new myadapter(contacts.this, android.r.layout.simple_list_item_1, r.id.textview1, getresources().getstringarray(r.array.contacts_list))); } 

after there subclass extends arrayadapter custom list. have not displayed part.

[1]: http://androidrises.blogspot.in/2012/10/tabactivity-example.html see link , make 2 tabs explained in it, , use same custom adapter both tabs , if problem persist let me know


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -