0

I have seen many examples around, but I could not understand how to have the navigation drawer, always open in the tablet. I'm using this navigation drawer https://github.com/kanytu/android-material-drawer-template. I will have to create another xml file? and in OnCreate () what kind of code I need to add?

public class MainActivity extends AppCompatActivity implements NavigationDrawerCallbacks {

    private Toolbar mToolbar;
    private NavigationDrawerFragment mNavigationDrawerFragment;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mToolbar = (Toolbar) findViewById(R.id.toolbar_actionbar);
        setSupportActionBar(mToolbar);
        getSupportActionBar().setDisplayShowHomeEnabled(true);


        mNavigationDrawerFragment = (NavigationDrawerFragment) getFragmentManager().findFragmentById(R.id.fragment_drawer);
        mNavigationDrawerFragment.setup(R.id.fragment_drawer, (DrawerLayout) findViewById(R.id.drawer), mToolbar);
    }
     @Override
    public void onNavigationDrawerItemSelected(int position) {
    FragmentManager fragmentManager = getFragmentManager();
    ..
    ..
    }

    @Override
    public void onBackPressed() {
        if (mNavigationDrawerFragment.isDrawerOpen())
            mNavigationDrawerFragment.closeDrawer();
        else
            super.onBackPressed();
    }


        public void onResume() {
            super.onResume();

        }


}
Bacteria
  • 8,406
  • 10
  • 50
  • 67
JJkk
  • 133
  • 1
  • 9
  • Possible duplicate of [Navigation Drawer: set as always opened on tablets](https://stackoverflow.com/questions/17133541/navigation-drawer-set-as-always-opened-on-tablets/50646711#50646711) – Bertram Gilfoyle Jul 04 '18 at 17:03

1 Answers1

0

I do not have the precise knowledge but a workaround could be to make a different xml file for large devices without the DrawerLayout so when it runs on a tablet it will return null and no other boolean will be neede in the code and this will make the coding part very simple :-) kudos !