Back to project page android-menudrawer.
The source code is released under:
Apache License
If you think the Android project android-menudrawer listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package net.simonvt.menudrawer.samples; /*from w w w . j a v a 2 s .c o m*/ import net.simonvt.menudrawer.MenuDrawer; import net.simonvt.menudrawer.Position; import android.os.Build; import android.os.Bundle; import android.view.MenuItem; import android.view.View; import android.widget.SeekBar; import android.widget.TextView; public class LeftDrawerSample extends BaseListSample { private static final String STATE_CONTENT_TEXT = "net.simonvt.menudrawer.samples.LeftDrawerSample.contentText"; private String mContentText; private TextView mContentTextView; @Override protected void onCreate(Bundle inState) { super.onCreate(inState); if (inState != null) { mContentText = inState.getString(STATE_CONTENT_TEXT); } mMenuDrawer.setContentView(R.layout.activity_contentsample); mMenuDrawer.setTouchMode(MenuDrawer.TOUCH_MODE_FULLSCREEN); mMenuDrawer.setSlideDrawable(R.drawable.ic_drawer); mMenuDrawer.setDrawerIndicatorEnabled(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { getActionBar().setDisplayHomeAsUpEnabled(true); } mContentTextView = (TextView) findViewById(R.id.contentText); mContentTextView.setText(mContentText); mMenuDrawer.setOnInterceptMoveEventListener(new MenuDrawer.OnInterceptMoveEventListener() { @Override public boolean isViewDraggable(View v, int dx, int x, int y) { return v instanceof SeekBar; } }); } @Override protected void onMenuItemClicked(int position, Item item) { mContentTextView.setText(item.mTitle); mMenuDrawer.closeMenu(); } @Override protected int getDragMode() { return MenuDrawer.MENU_DRAG_CONTENT; } @Override protected Position getDrawerPosition() { return Position.START; } @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putString(STATE_CONTENT_TEXT, mContentText); } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: mMenuDrawer.toggleMenu(); return true; } return super.onOptionsItemSelected(item); } @Override public void onBackPressed() { final int drawerState = mMenuDrawer.getDrawerState(); if (drawerState == MenuDrawer.STATE_OPEN || drawerState == MenuDrawer.STATE_OPENING) { mMenuDrawer.closeMenu(); return; } super.onBackPressed(); } }