I've built an app that uses TabLayout. Each tab displays correctly in a
scrollable horizontal toolbar. However, it displays the layout for Tab 1,
by default and I do not want anything displayed until the onTabSelected
code is fired. ie; Do not display anything (except for the tabs) until I
click/select a specific tab. Whatever layout associated with the tab is
displayed without my selecting the tab. Providing a solution would be
greatly appreciated.
Here's relevant code:
setContentView(R.layout.main_activity_scrollable_tabs);
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
viewPager = (ViewPager) findViewById(R.id.viewpager);
setupViewPager(viewPager);
tabLayout = (TabLayout) findViewById(R.id.main_tabs);
tabLayout.setupWithViewPager(viewPager);
tabLayout.addOnTabSelectedListener(
new TabLayout.ViewPagerOnTabSelectedListener(viewPager) {
@Override
public void onTabSelected(TabLayout.Tab tab) {
super.onTabSelected(tab);
Intent intent;
// position zero-based! ie; tab one is pos 0.
numTab = tab.getPosition();
switch (numTab) {
case 0:
intent = new Intent(context, PeopleEntryActivity.class);
startActivityForResult(intent, 0);
--
You received this message because you are subscribed to the Google Groups
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit
https://groups.google.com/d/msgid/android-developers/ecb3c973-b271-4b7e-9e98-0250ae88013c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.