@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); // SlideMode MenuItem item = menu.findItem(R.id.menu_slide_mode); item.setTitle("切换SlideMode:" + mSlideListView.getSlideMode().toString()); // SlideLeftAction item = menu.findItem(R.id.menu_slide_left_action); item.setTitle("切换SlideLeftAction:" + mSlideListView.getSlideLeftAction().toString()); // SlideRightAction item = menu.findItem(R.id.menu_slide_right_action); item.setTitle("切换SlideRightAction:" + mSlideListView.getSlideRightAction().toString()); return true; }
private void changeSlideMode(MenuItem item) { if (mSlideListView.getSlideMode() == SlideMode.BOTH) { mSlideListView.setSlideMode(SlideMode.LEFT); } else if (mSlideListView.getSlideMode() == SlideMode.LEFT) { mSlideListView.setSlideMode(SlideMode.RIGHT); } else if (mSlideListView.getSlideMode() == SlideMode.RIGHT) { mSlideListView.setSlideMode(SlideMode.NONE); } else if (mSlideListView.getSlideMode() == SlideMode.NONE) { mSlideListView.setSlideMode(SlideMode.BOTH); } if (item != null) { item.setTitle("切换SlideMode:" + mSlideListView.getSlideMode().toString()); } Toast.makeText( this, "切换SlideMode:" + mSlideListView.getSlideMode().toString(), Toast.LENGTH_SHORT) .show(); }