Note that there are some explanatory texts on larger screens.

plurals
  1. PODifferent style of navigation - Phone vs Tablet?
    primarykey
    data
    text
    <p>I am fairly good in fragments API, I know how to create master/detail pattern on phone/tablet. <strong>But how would I create a different style of navigation in phones and tablets?</strong> </p> <p>The most obvious example would be swiping tabs on the phone and somekind tablet layout with all the fragments layed out inside, no swiping tabs.</p> <p>Is there some elegant way of doing this other than giant if statement?</p> <p><img src="https://i.stack.imgur.com/KCo5A.jpg" alt="enter image description here"></p> <p><strong>//EDIT</strong></p> <p>So what would you do, as I presumed, is to create create two layouts (phone - view pager / tablet - three static fragments) and in activity's onCreate check for something in the layout to figure out wether youre in phone or tablet. <strong>Then just initialize the tabs navigation / or not if youre in tablet.</strong> That should work.</p> <p><em>CODE SNIPPETS FROM IO 2012 APP</em></p> <pre><code>@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_home); FragmentManager fm = getSupportFragmentManager(); mViewPager = (ViewPager) findViewById(R.id.pager); if (mViewPager != null) { // Phone setup mViewPager.setAdapter(new HomePagerAdapter(getSupportFragmentManager())); mViewPager.setOnPageChangeListener(this); final ActionBar actionBar = getSupportActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.addTab(actionBar.newTab() .setText(R.string.title_my_schedule) .setTabListener(this)); actionBar.addTab(actionBar.newTab() .setText(R.string.title_explore) .setTabListener(this)); actionBar.addTab(actionBar.newTab() .setText(R.string.title_stream) .setTabListener(this)); homeScreenLabel = getString(R.string.title_my_schedule); } else { //Tablet setup mExploreFragment = (ExploreFragment) fm.findFragmentById(R.id.fragment_tracks); mMyScheduleFragment = (MyScheduleFragment) fm.findFragmentById(R.id.fragment_my_schedule); mSocialStreamFragment = (SocialStreamFragment) fm.findFragmentById(R.id.fragment_stream); } } </code></pre> <p>Any of you guys that already have tabs navigation on phone, please consider implementing this on the tablet, if it works for you design-wise. You already have fragments api ready, so there's no excuse, really.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload