Java Code Examples for android.support.v4.widget.DrawerLayout#closeDrawer()
The following examples show how to use
android.support.v4.widget.DrawerLayout#closeDrawer() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainActivity.java From Modularity with Apache License 2.0 | 6 votes |
@Override @SuppressWarnings("StatementWithEmptyBody") public boolean onNavigationItemSelected(MenuItem item) { // Handle navigation view item clicks here. int id = item.getItemId(); if (id == R.id.nav_camera) { } else if (id == R.id.nav_gallery) { } else if (id == R.id.nav_slideshow) { } else if (id == R.id.nav_manage) { ActivityRouter.startActivity(this, RouterList.EXPLORER_ATY_MAIN); } else if (id == R.id.nav_share) { ActivityRouter.startActivity(this, RouterList.MEMORY_ATY_MAIN); } else if (id == R.id.nav_send) { throw new RuntimeException("throw exception"); } DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; }
Example 2
Source File: MainActivity.java From YoutubeDown with MIT License | 6 votes |
@SuppressWarnings("StatementWithEmptyBody") @Override public boolean onNavigationItemSelected(MenuItem item) { // Handle navigation view item clicks here. int id = item.getItemId(); if (id == R.id.nav_camera) { // Handle the camera action } else if (id == R.id.nav_gallery) { } else if (id == R.id.nav_slideshow) { } else if (id == R.id.nav_manage) { } else if (id == R.id.nav_share) { } else if (id == R.id.nav_send) { } DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; }
Example 3
Source File: MainActivity.java From Weather-Lite with Apache License 2.0 | 6 votes |
@SuppressWarnings("StatementWithEmptyBody") @Override public boolean onNavigationItemSelected(MenuItem item) { // Handle navigation view item clicks here. int id = item.getItemId(); // if (id == R.id.nav_camera) { // // Handle the camera action // } else if (id == R.id.nav_gallery) { // // } else if (id == R.id.nav_slideshow) { // // } else if (id == R.id.nav_manage) { // // } else if (id == R.id.nav_share) { // // } else if (id == R.id.nav_send) { // // } DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; }
Example 4
Source File: MainActivity.java From ClipPathLayout with Apache License 2.0 | 6 votes |
@SuppressWarnings("StatementWithEmptyBody") @Override public boolean onNavigationItemSelected(MenuItem item) { // Handle navigation view item clicks here. int id = item.getItemId(); if (id == R.id.nav_circle_path) { switchFragment(new CirclePathFragment()); } else if (id == R.id.nav_control_button) { switchFragment(new ControlButtonFragment()); } else if (id == R.id.nav_remote_controller) { switchFragment(new RemoteControllerFragment()); } else if (id == R.id.yin_yang_fish) { switchFragment(new YinYangFishFragment()); } else if (id == R.id.nav_view_transition) { switchFragment(new ViewTransitionFragment()); } else if (id == R.id.nav_scroll_transition) { switchFragment(new ScrollTransitionFragment()); } DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; }
Example 5
Source File: MainActivity.java From Travel-Mate with MIT License | 5 votes |
@Override public void onBackPressed() { DrawerLayout drawer = findViewById(R.id.drawer_layout); if (drawer != null && drawer.isDrawerOpen(GravityCompat.START)) { drawer.closeDrawer(GravityCompat.START); } else { super.onBackPressed(); } }
Example 6
Source File: MainActivity.java From arcgis-runtime-demos-android with Apache License 2.0 | 5 votes |
@Override public boolean onNavigationItemSelected(MenuItem item) { // Handle navigation view item clicks here. int id = item.getItemId(); Viewpoint selectedViewpoint = null; if (id == R.id.nav_world_location1) { selectedViewpoint = mViewpoint1; } else if (id == R.id.nav_world_location2) { selectedViewpoint = mViewpoint2; } else if (id == R.id.nav_world_location3) { selectedViewpoint = mViewpoint3; } else if (id == R.id.nav_world_location4) { selectedViewpoint = mViewpoint4; } // If new target already inside the current extent, then zoom directly to it. if (GeometryEngine.intersects(mMapView.getVisibleArea(), selectedViewpoint.getTargetGeometry())) { jumpZoom(selectedViewpoint, null); } else { // If target is outside of current extent, zoom out first to see both extents, then zoom back in. Geometry union = GeometryEngine.union(mMapView.getVisibleArea().getExtent().getCenter(), selectedViewpoint .getTargetGeometry()); if ((union != null) && (!union.isEmpty())) { jumpZoom(new Viewpoint(union.getExtent()), selectedViewpoint); } } DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; }
Example 7
Source File: GeocodeRouteActivity.java From arcgis-runtime-demos-android with Apache License 2.0 | 5 votes |
@Override public void onBackPressed() { // If back button is pressed while in activity and the navigation drawer is open, then close the navigation drawer. // Otherwise, delegate to the activity. DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); if (drawer.isDrawerOpen(GravityCompat.START)) { drawer.closeDrawer(GravityCompat.START); } else { super.onBackPressed(); } }
Example 8
Source File: MainActivity.java From stockita-point-of-sale with MIT License | 5 votes |
@Override public void onBackPressed() { DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); if (drawer.isDrawerOpen(GravityCompat.START)) { drawer.closeDrawer(GravityCompat.START); } else { super.onBackPressed(); } }
Example 9
Source File: Dashboard.java From BloodBank with GNU General Public License v3.0 | 5 votes |
@Override public void onBackPressed() { DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); if (drawer.isDrawerOpen(GravityCompat.START)) { drawer.closeDrawer(GravityCompat.START); } else { super.onBackPressed(); } }
Example 10
Source File: MainActivity.java From AndResGuard with Apache License 2.0 | 5 votes |
@Override public void onBackPressed() { DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); if (drawer.isDrawerOpen(GravityCompat.START)) { drawer.closeDrawer(GravityCompat.START); } else { super.onBackPressed(); } }
Example 11
Source File: MainActivity.java From AndroidBleManager with Apache License 2.0 | 5 votes |
@Override public void onBackPressed() { DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); if (drawer.isDrawerOpen(GravityCompat.START)) { drawer.closeDrawer(GravityCompat.START); } else { super.onBackPressed(); } }
Example 12
Source File: MainActivity.java From android-app with The Unlicense | 5 votes |
@Override public void onBackPressed() { DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); if (drawer.isDrawerOpen(GravityCompat.START)) { drawer.closeDrawer(GravityCompat.START); } else { super.onBackPressed(); } }
Example 13
Source File: MainActivity.java From nono-android with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings("StatementWithEmptyBody") @Override public boolean onNavigationItemSelected(MenuItem item) { // Handle navigation view item clicks here. findViewById(R.id.note_fab_add).setVisibility(View.VISIBLE); btn_new_group.setVisibility(View.GONE); btn_new_label.setVisibility(View.GONE); mountPostNote(); switch (item.getItemId()) { case R.id.nav_note_all: transFragment("全部"); break; case R.id.nav_recycle_bin: transFragment("回收站"); break; case R.id.nav_note_group: btn_new_group.setVisibility(View.VISIBLE); transFragment("文集"); break; case R.id.nav_note_date: transFragment("日期"); break; case R.id.nav_quickask_question: mountPostQuestion(); transFragment("答记"); //findViewById(R.id.note_fab_add).setVisibility(View.GONE); break; case R.id.nav_note_label: btn_new_label.setVisibility(View.VISIBLE); transFragment("标签"); break; } DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; }
Example 14
Source File: MainActivity.java From aware with MIT License | 5 votes |
@Override public void onBackPressed() { DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); if (drawer.isDrawerOpen(GravityCompat.START)) { drawer.closeDrawer(GravityCompat.START); } else { super.onBackPressed(); } }
Example 15
Source File: HomeActivity.java From Hillffair17 with GNU General Public License v3.0 | 5 votes |
@Override public void onBackPressed(){ DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); if (drawer.isDrawerOpen(GravityCompat.START)) { drawer.closeDrawer(GravityCompat.START); } else { super.onBackPressed(); } }
Example 16
Source File: MainActivity.java From android-samples with Apache License 2.0 | 5 votes |
@SuppressWarnings("StatementWithEmptyBody") @Override public boolean onNavigationItemSelected(MenuItem item) { // Handle navigation view item clicks here. int id = item.getItemId(); if (id == R.id.nav_insertdata) { fragment=new InsertFragment(); } else if (id == R.id.nav_viewdata) { fragment=new DisplayFragment(); ArrayList<Data> output=(ArrayList)database.readData(); Bundle bundle=new Bundle(); bundle.putParcelableArrayList("data",output); bundle.putString(" ",output.toString()); fragment.setArguments(bundle); } if(fragment!=null) { FragmentTransaction ft=getSupportFragmentManager().beginTransaction(); ft.replace(R.id.content_main,fragment); ft.commit(); } DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; }
Example 17
Source File: MainActivity.java From Learning-Resources with MIT License | 5 votes |
@Override public void onBackPressed() { DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); if (drawer.isDrawerOpen(GravityCompat.START)) { drawer.closeDrawer(GravityCompat.START); } else { super.onBackPressed(); } }
Example 18
Source File: MainActivity.java From Password-Storage with MIT License | 5 votes |
@Override public boolean onNavigationItemSelected(@NonNull MenuItem item) { switch (item.getItemId()){ case R.id.nav_logout: Toast.makeText(getApplicationContext(), R.string.main_logout, Toast.LENGTH_LONG).show(); SplashActivity.editor.remove("loginTest"); SplashActivity.editor.commit(); Intent sendToLoginAndRegistration = new Intent(getApplicationContext(), LoginActivity.class); startActivity(sendToLoginAndRegistration); break; case R.id.nav_settings: Intent settings = new Intent(MainActivity.this, SettingsActivity.class); settings.putExtra("email", getIntent().getStringExtra("email")); startActivity(settings); break; case R.id.nav_share: Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND); sharingIntent.setType("text/plain"); String shareBodyText = "Are you frustrated with remembering numerous passwords, and want a secure way of saving them paperlessly? Download the app now and memorize only one master password! https://goo.gl/X1yJj2"; sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"Password Storage"); sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBodyText); startActivity(Intent.createChooser(sharingIntent, "Sharing Option")); break; case R.id.nav_about_us: Intent sendToAboutUs = new Intent(getApplicationContext(), AboutUsActivity.class); startActivity(sendToAboutUs); break; } DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; }
Example 19
Source File: MainActivity.java From swipe-maker with Apache License 2.0 | 4 votes |
@SuppressWarnings("StatementWithEmptyBody") @Override public boolean onNavigationItemSelected(MenuItem item) { int id = item.getItemId(); switch(id){ case R.id.nav_rightswipe: { showFragment(RightSwipeFragment.newInstance(), RightSwipeFragment.TAG); break; } case R.id.nav_half_swipe: { showFragment(HalfRightSwipeFragment.newInstance(), HalfRightSwipeFragment.TAG); break; } case R.id.nav_two_step_swipe: { showFragment(TwoStepRightSwipeFragment.newInstance(), TwoStepRightSwipeFragment.TAG); break; } case R.id.nav_both_side_swipe: { showFragment(BothSideSwipeFragment.newInstance(), BothSideSwipeFragment.TAG); break; } case R.id.nav_right_drag_swipe: { showFragment(HalfRightDragSwipeFragment.newInstance(), HalfRightDragSwipeFragment.TAG); break; } case R.id.nav_right_drag_friction_swipe: { showFragment(HalfRightDragFrictionSwipeFragment.newInstance(), HalfRightDragFrictionSwipeFragment.TAG); break; } case R.id.nav_swing_swipe: { showFragment(SwingSwipeFragment.newInstance(), SwingSwipeFragment.TAG); break; } case R.id.nav_vertical_swipe: { showFragment(VerticalSwipeFragment.newInstance(), VerticalSwipeFragment.TAG); break; } case R.id.nav_share: { launchSharer(); break; } } DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; }
Example 20
Source File: MainActivity.java From Android-POS with MIT License | 4 votes |
public void closeNavBar(){ DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); if (drawer.isDrawerOpen(GravityCompat.START)) { drawer.closeDrawer(GravityCompat.START); } }