How to add dynamic tabs and dynamic expandable list view inside it in android? -


i want create tabs dynamically according number category available.inside each tab need create number of expandable list views dynamically inside each tab.(example: got 4 categories education,sports,science,aerospace.) need create 4 tabs on run time, change according number categories getting(one or twenty or more).

inside each tab need create number of expandable list views(dynamically).

after long surfing found related links here1 here2 here3 , more.but prefer go proper , efficient method not aware of.

need help,thanks in advance.

you need consider this

tab2 = tab3 = tab1 = fragement---- in can expandable listview defined in layout reference of tab's need update expandable listview.

for dynamic tabview can should specify tabspec either specifying

the id of view, or tabhost.tabcontentfactory creates view content code both!

change code 1 of following:

for (int i=1; i<=n; i++){    final string tabname = "tab" + integer.tostring(i);    final tabspec ourspec = th.newtabspec(tabname);    ourspec.setcontent(new tabhost.tabcontentfactory() {        public view createtabcontent(string tag) {            textview text = new textview(newticket.this);           string tabtext = tabname;           text.settext("you've created new tab " + tabtext);            return (text);       }    });    ourspec.setindicator(tabname);    tabhost.addtab(ourspec);   }  or   (int i=1; i<=n; i++){    final string tabname = "tab" + integer.tostring(i);    final tabspec ourspec = th.newtabspec(tabname);    ourspec.setcontent(r.id.llitemlist);       ourspec.setindicator(tabname);     tabhost.addtab(ourspec);   } 

to preserve same instance of listview, mentioned in comment, following:

register tabhost.ontabchangelistener when tab changes, should first call removeview() on listview's current parent , addview() new parent.


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -