Android Tabbed Application -


i tried implement application have 2 tabs in top.

each of tabs shows listview, difference listview filled different content arraylist.

i tried several steps fulfil task, stuff on web deprecated. advise way actual state of art?

as said: managed find lot of tutorials task, again, of them 2012 or , android studio marks them deprecated.

would nice, have advices!

edit: tried implement:

a tabhostsolution:

  tabhost tabhost = (tabhost)findviewbyid(android.r.id.tabhost);                     tabspec tab1 = tabhost.newtabspec("first tab");                     tabspec tab2 = tabhost.newtabspec("second tab");                     tabspec tab3 = tabhost.newtabspec("third tab");                       tab1.setindicator("tab1");                     tab1.setcontent(new intent(this,tab1activity.class));                      tab2.setindicator("tab2");                     tab2.setcontent(new intent(this,tab2activity.class));                     tabhost.addtab(tab1);                     tabhost.addtab(tab2); 

also tried apply tabs actionbar this. problem line actionbar actionbar = getsupportactionbar returned null:

actionbar actionbar = getsupportactionbar();     actionbar.setnavigationmode(actionbar.navigation_mode_tabs);     actionbar.setdisplayshowtitleenabled(false);      tab tab = actionbar.newtab()                        .settext(r.string.artist)                        .settablistener(new tablistener<artistfragment>(                                this, "artist", artistfragment.class));     actionbar.addtab(tab); 

and several other attemps, deleted already.

i use this tutorials , work fine. use fragments achieve that.


Comments