Android TabLayout (API 22) add fragment to each tab without ViewPager -
i'm trying out android's new tablayout class add 2 tabs below actionbar. each tab host different fragment. also, don't want able swipe between 2 tabs - navigate between tabs, i'd able touch tab want navigate to. inside mainactivity, have: public class mainactivity extends actionbaractivity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); tablayout tablayout = (tablayout) findviewbyid(r.id.tab_layout); tablayout.addtab(tablayout.newtab().settext("newsfeed")); tablayout.addtab(tablayout.newtab().settext("random")); tablayout.setontabselectedlistener(new tablayout.ontabselectedlistener() { @override public void ontabselected(tablayout.tab tab) { // ideally here, i'd // tab.setfragment(new mainfragment()). } @override public void ontabunselected(tablayout.tab