private void initilizeViewVariables() { clearDescriptionButton = (Button) findViewById(R.id.descriptionCLRbtn); clearTitleButton = (Button) findViewById(R.id.titleCLRbtn); notifySwitch = (Switch) findViewById(R.id.switchNotificationLO); repeatSpinner = (Spinner) findViewById(R.id.spinnerRepeatingLO); timepicker = (TimePicker) findViewById(R.id.timePickerLO); datepicker = (DatePicker) findViewById(R.id.datePickerLO); timepicker.setIs24HourView(true); titleInputext = (EditText) findViewById(R.id.TitleEditTextLO); titleInputext.requestFocus(); descriptionInputText = (EditText) findViewById(R.id.descriptionEditTextLO); repeatAdapter = new ArrayAdapter<String>( this, android.R.layout.simple_spinner_item, getResources().getStringArray(R.array.repeatArray)); repeatSpinner.setAdapter(repeatAdapter); clearDescriptionButton.setOnClickListener(this); clearTitleButton.setOnClickListener(this); drawer.setOnOpenListener(this); drawer.setOnCloseListener(this); notifySwitch.setOnCheckedChangeListener(this); initilizeVariables(); inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); if (inputMethodManager != null) { inputMethodManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); } }
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { // TODO Auto-generated method stub if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_HOME) { // 如果此时侧栏展开,则让其收起 if (slidingMenu.isActivated()) { slidingMenu.toggle(); // 返回true让程序不退出 return true; } // 如果是编辑模式则退出编辑模式 if (editmodel) { toNormal(); return true; } if ((System.currentTimeMillis() - exitTime) > 2000) { Toast.makeText(MainActivity.this, "再按一次退出程序", Toast.LENGTH_SHORT).show(); exitTime = System.currentTimeMillis(); } else { MainActivity.this.finish(); System.exit(0); } return true; } return super.onKeyDown(keyCode, event); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.personal); ////////////////// Bitmap bm = BitmapFactory.decodeResource(this.getResources(), R.drawable.background_personal); BitmapDrawable bd = new BitmapDrawable(this.getResources(), bm); allLayout = (RelativeLayout) findViewById(R.id.layout_personal); allLayout.setBackgroundDrawable(bd); ////////////////// btnPersonal = (Button) findViewById(R.id.btnPersonal); btnExpert = (Button) findViewById(R.id.btnExpert); btnMessage = (Button) findViewById(R.id.btnMessage); btnPersonal.setOnClickListener(new MyButtonOnClickListener()); btnExpert.setOnClickListener(new MyButtonOnClickListener()); btnMessage.setOnClickListener(new MyButtonOnClickListener()); ////////////////// final SlidingMenu menu = new SlidingMenu(this); btnDetails = (Button) findViewById(R.id.btnDetails); btnDetails.setOnClickListener( new OnClickListener() { public void onClick(View v) { menu.toggle(); } }); menu.setMode(SlidingMenu.LEFT); menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN); menu.setShadowWidthRes(R.dimen.shadow_width); menu.setShadowDrawable(R.drawable.shadow); menu.setBehindOffsetRes(R.dimen.slidingmenu_offset); menu.setBehindWidth(500); menu.setFadeDegree(0.35f); menu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT); menu.setMenu(R.layout.sliding_detalis); ////////////////// btnPersonalData = (Button) findViewById(R.id.btnPersonalData); btnEveryDay = (Button) findViewById(R.id.btnEveryDay); btnMyPlan = (Button) findViewById(R.id.btnMyPlan); btnMyTeacher = (Button) findViewById(R.id.btnMyTeacher); btnMyCollection = (Button) findViewById(R.id.btnMyCollection); btnMyCard = (Button) findViewById(R.id.btnMyCard); btnPersonalData.setOnClickListener(new MyButtonOnClickListener()); btnEveryDay.setOnClickListener(new MyButtonOnClickListener()); btnMyPlan.setOnClickListener(new MyButtonOnClickListener()); btnMyTeacher.setOnClickListener(new MyButtonOnClickListener()); btnMyCollection.setOnClickListener(new MyButtonOnClickListener()); btnMyCard.setOnClickListener(new MyButtonOnClickListener()); }
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); slidingMenu = new SlidingMenu(MonthActivity.this); if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { setContentView(R.layout.main); slidingMenu.setBehindOffset((int) (getResources().getDisplayMetrics().widthPixels * 0.15)); } else { setContentView(R.layout.main); slidingMenu.setBehindOffset((int) (getResources().getDisplayMetrics().widthPixels * 0.5)); Fragment newFragment = new DetailDayFragment(); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.add(R.id.day_or_pair_frame, newFragment).commit(); } slidingMenu.setMode(SlidingMenu.LEFT); slidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN); slidingMenu.attachToActivity(this, SlidingMenu.SLIDING_WINDOW); slidingMenu.setMenu(R.layout.sliding_menu); slidingMenu .findViewById(R.id.sliding_menu_lessons) .setOnClickListener(new LessonsItemOnClick()); slidingMenu .findViewById(R.id.sliding_menu_teachers) .setOnClickListener(new TeachersItemOnClick()); getSupportActionBar().setDisplayHomeAsUpEnabled(true); new TestData().addingTo(AppDB.getInstance(this)); }
/** * Finds a view that was identified by the id attribute from the XML that was processed in * onCreate(Bundle). * * @param id the resource id of the desired view * @return The view if found or null otherwise. */ public View findViewById(int id) { View v; if (mSlidingMenu != null) { v = mSlidingMenu.findViewById(id); if (v != null) return v; } return null; }
@Override public boolean onOptionsItemSelected(MenuItem item) { boolean isValid = false; switch (item.getItemId()) { case R.id.savetaskMI: isValid = editATaskAction(); if (isValid == true) finish(); break; case R.id.addtaskMI: isValid = createATaskAction(); if (isValid == true) { initilizeVariables(); initilizeForNewTask(); titleInputext.setText(""); descriptionInputText.setText(""); if (drawer.isMenuShowing()) drawer.toggle(); toastWithGravity("Task Added!"); } EasyTracker.getTracker() .sendEvent("UI-ActionBar", "Add Task-Append", "ActionBar", (long) 0); break; case R.id.proximityMI: AlertDialog diaBox = locationEditText(); diaBox.show(); EasyTracker.getTracker().sendEvent("UI-ActionBar", "Add Proximity", "ActionBar", (long) 0); break; case R.id.alarmMI: drawer.toggle(false); EasyTracker.getTracker() .sendEvent("UI-ActionBar", "Toggle Alarm Menu", "ActionBar", (long) 0); break; case R.id.backMI: EasyTracker.getTracker().sendEvent("UI-ActionBar", "back To Main", "ActionBar", (long) 0); finish(); break; } return super.onOptionsItemSelected(item); }
/** * public boolean onCreateOptionsMenu(android.view.Menu menu) { super.onCreateOptionsMenu(menu); * MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.sidemapmenu, menu); return * true; } * */ @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: sm.toggle(); return true; } return super.onOptionsItemSelected(item); }
@Override public boolean onKeyDown(int keycode, KeyEvent e) { switch (keycode) { case KeyEvent.KEYCODE_MENU: drawer.toggle(false); return true; } return super.onKeyDown(keycode, e); }
@Override public void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_NO_TITLE); if (Build.VERSION.SDK_INT > 10) { getWindow().setFlags(0x01000000, 0x01000000); } super.onCreate(savedInstanceState); Bundle bundle = new Bundle(); if (getIntent() != null) { Serializable serializable = getIntent().getSerializableExtra("SUBLIST"); bundle.putSerializable("SUBLIST", serializable); } if (savedInstanceState != null) { weatherCitySelectFragment = (WeatherCitySelectFragment) getSupportFragmentManager() .getFragment(savedInstanceState, "WeatherCitySelectFragment"); weatherSettingFragment = (WeatherSettingFragment) getSupportFragmentManager().getFragment(savedInstanceState, "WeatherSettingFragment"); } if (weatherCitySelectFragment == null) { weatherCitySelectFragment = WeatherCitySelectFragment.newInstance(bundle); } if (weatherSettingFragment == null) { weatherSettingFragment = new WeatherSettingFragment(); } // set the Behind View setBehindContentView(R.layout.menu_frame); FragmentTransaction t = this.getSupportFragmentManager().beginTransaction(); t.replace(R.id.menu_frame, weatherCitySelectFragment); t.commit(); // customize the SlidingMenu SlidingMenu sm = getSlidingMenu(); sm.setMode(SlidingMenu.LEFT_RIGHT); sm.setShadowWidthRes(R.dimen.shadow_width); sm.setShadowDrawable(R.drawable.shadow); sm.setBehindOffsetRes(R.dimen.slidingmenu_offset); sm.setFadeDegree(0.35f); sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN); sm.setSecondaryMenu(R.layout.menu_frame_two); sm.setSecondaryShadowDrawable(R.drawable.shadowright); getSupportFragmentManager() .beginTransaction() .replace(R.id.menu_frame_two, weatherSettingFragment) .commit(); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.map_frame_content); setBehindContentView(R.layout.map_frame_left_menu); setSecondaryBehindContentView(R.layout.map_frame_right_menu); Button left = (Button) findViewById(R.id.map_left); left.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { toggle(); } }); Button right = (Button) findViewById(R.id.map_right); right.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { showSecondaryMenu(); } }); // mMapView = (MapView)findViewById(R.id.mapview); // if (mMapView == null) { // return; // } // mMapView.addLayer(new // ArcGISTiledMapServiceLayer(getResources().getString(R.string.map_url))); FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); MapLeftMenuFragment leftMenuFragment = new MapLeftMenuFragment(); MapRightMenuFragment rightMenuFragment = new MapRightMenuFragment(); MapContentFragment mapFragment = new MapContentFragment(); fragmentTransaction.replace(R.id.map_left_menu, leftMenuFragment); fragmentTransaction.replace(R.id.map_right_menu, rightMenuFragment); fragmentTransaction.replace(R.id.map_content, mapFragment); fragmentTransaction.commit(); // customize the SlidingMenu SlidingMenu sm = getSlidingMenu(); sm.setShadowWidth(50); sm.setShadowDrawable(R.drawable.shadow); sm.setBehindOffset(200); sm.setFadeDegree(0.35f); sm.setMode(SlidingMenu.LEFT_RIGHT); // 设置slding menu的几种手势模式 // TOUCHMODE_FULLSCREEN 全屏模式,在content页面中,滑动,可以打开sliding menu // TOUCHMODE_MARGIN 边缘模式,在content页面中,如果想打开slding ,你需要在屏幕边缘滑动才可以打开slding menu // TOUCHMODE_NONE 自然是不能通过手势打开啦 sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_NONE); // 使用左上方icon可点,这样在onOptionsItemSelected里面才可以监听到R.id.home // getActionBar().setDisplayHomeAsUpEnabled(true); }
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: { slidingMenu.toggle(true); } } return super.onOptionsItemSelected(item); }
/** * On key up. * * @param keyCode the key code * @param event the event * @return true, if successful */ public boolean onKeyUp(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && mSlidingMenu.isMenuShowing()) { if (mCloseOnBack) { mActivity.finish(); } else { showContent(); } return true; } return false; }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.create_layout); // ActionBar gets initiated actionBar = getSupportActionBar(); actionBar = getSupportActionBar(); actionBar.setDisplayShowHomeEnabled(true); actionBar.setDisplayShowTitleEnabled(true); actionBar.setTitle("Compose"); myDataBase = new TaskDataBaseSQL(this); drawer = new SlidingMenu(this); drawer.setMode(SlidingMenu.LEFT); drawer.setShadowDrawable(R.drawable.shadow); drawer.setShadowWidthRes(R.dimen.shadow_width); drawer.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN); drawer.setFadeDegree(0.35f); drawer.setBehindOffsetRes(R.dimen.slidingmenu_offset); drawer.attachToActivity(this, SlidingMenu.SLIDING_CONTENT); drawer.offsetTopAndBottom(25); drawer.setMenu(R.layout.alarmslidingmenu); drawer.setSlidingEnabled(false); positionOftaskToEdit = -1; initilizeViewVariables(); coder = new Geocoder(this); myGPSManager = new TaskGPSManager(this); myalarmmanager = new MyAlarmManager(this); timepicker.setCurrentHour(myalarmmanager.getHourOfDay()); if (getIntent().hasExtra("ob")) { positionOftaskToEdit = getIntent().getIntExtra("ob", 0); taskBeforeEdit = TaskList.getTasksList().get(positionOftaskToEdit); initilizeViewForExistingTask(); actionBar.setTitle("Edit"); Log.d(getClass().getSimpleName(), "Editing A Task" + "id: " + taskBeforeEdit.getTaskId()); } else { initilizeForNewTask(); Log.d(getClass().getSimpleName(), "Creating New Task"); } }
private void setMenu() { FrameLayout fl = new FrameLayout(this); fl.setId(99); this.setBehindContentView(fl); android.app.FragmentTransaction ft = getFragmentManager().beginTransaction(); MenuFragment_ menuFragment = new MenuFragment_(); ft.replace(99, menuFragment); ft.commit(); sm = this.getSlidingMenu(); sm.setBehindOffset(ConfigStatic.MENU_OFFSET); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTheme(R.style.DrawerTheme); // setTitle(mTitleRes); // set the Behind View setBehindContentView(R.layout.menu_scrollview); final ActionBar actionbar = getActionBar(); actionbar.setDisplayShowTitleEnabled(false); actionbar.setDisplayHomeAsUpEnabled(true); getActionBar().setDisplayHomeAsUpEnabled(true); // customize the SlidingMenu sm = getSlidingMenu(); sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN); sm.setMode(SlidingMenu.LEFT); sm.setBehindOffsetRes(R.dimen.slidingmenu_offset); sm.setShadowDrawable(R.drawable.shadow); sm.setShadowWidthRes(R.dimen.shadow_width); sm.setShadowWidthRes(R.dimen.shadow_width); sm.setFadeEnabled(true); sm.setFadeEnabled(true); sm.setFadeDegree(0.95f); // sm.setSecondaryMenu(R.layout.sidemenumap); // sm.setSecondaryShadowDrawable(R.drawable.shadowright); sm.setBackgroundColor(0x000000000); getActionBar().setDisplayHomeAsUpEnabled(true); getSlidingMenu() .setOnOpenedListener( new OnOpenedListener() { public void onOpened() { getSlidingMenu().invalidate(); // mMap.setMyLocationEnabled(true); } }); findViewById(R.id.item1).setOnClickListener(this); findViewById(R.id.item2).setOnClickListener(this); findViewById(R.id.item3).setOnClickListener(this); findViewById(R.id.item4).setOnClickListener(this); findViewById(R.id.item5).setOnClickListener(this); findViewById(R.id.item9).setOnClickListener(this); findViewById(R.id.item10).setOnClickListener(this); findViewById(R.id.item11).setOnClickListener(this); findViewById(R.id.item12).setOnClickListener(this); findViewById(R.id.item13).setOnClickListener(this); }
public boolean editATaskAction() { setId(taskBeforeEdit.getTaskId()); setTitle(titleInputext.getText().toString().trim()); setDescription(descriptionInputText.getText().toString().trim()); setIsDone(taskBeforeEdit.getTaskDoneIndicator()); setImportant(taskBeforeEdit.getTaskImportantIndicator()); if (getTaskTitle() != null && getTaskTitle().length() > 0) { if (notifySwitch.isChecked() == true) { setIntervalFromSpinner(); TimeFromPickers = myalarmmanager.getTimeFromPickers(datepicker, timepicker); updateTaskAction(); setDifferenceInMillis(myalarmmanager.compareBetweenDates(TimeFromPickers)); boolean isLater = getDifferenceInMillis() != MyConstants.INVALID_TIME; if (isLater == true) { myalarmmanager.setAlarm(taskDummy, getDifferenceInMillis(), getRepeatAlarmInterval()); Log.i(getClass().getSimpleName(), "notify for: " + getId() + " changed"); return true; } else { toastWithGravity("Invalid Time" + "\n" + "Turn Off Switch or Pick A different Time"); TimeFromPickers = null; drawer.showMenu(true); return false; } } else { updateTaskAction(); if (taskBeforeEdit.getTaskNotificationDate() != null) { myalarmmanager.CancelAlarm(taskDummy); return true; } // if the notification switch is off and there where no notification before the editing // of the task, user want a task without any alarm else { return true; } } } else { toastWithGravity("First Fill in Task Title"); return false; } }
@Override protected void onCreate(Bundle bundle) { super.onCreate(bundle); // configure the SlidingMenu SlidingMenu menu = new SlidingMenu(this); menu.setMode(SlidingMenu.LEFT); menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN); menu.attachToActivity(this, SlidingMenu.SLIDING_WINDOW); menu.setShadowWidth(15); menu.setBehindOffset(60); menu.setFadeDegree(0.35f); menu.setMenu(R.layout.sidemenu_frame); getSupportFragmentManager() .beginTransaction() .replace(R.id.menu_frame, new SideMenu()) .commit(); }
@Override public void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.frame_content); setBehindContentView(R.layout.frame_menu); // setSecondaryMenu SlidingMenu sm = getSlidingMenu(); sm.setShadowWidth(50); sm.setShadowDrawable(R.drawable.shadow); sm.setBehindOffset(60); sm.setFadeDegree(0.35f); sm.setMode(SlidingMenu.LEFT_RIGHT); // sm.set sm.setSecondaryMenu(R.layout.test1); sm.setSecondaryShadowDrawable(R.drawable.shadow); // sm.setMenu(R.layout.frame_menu); // sm.setLeft(R.layout.frame_menu); // 设置slding menu的几种手势模式 // TOUCHMODE_FULLSCREEN 全屏模式,在content页面中,滑动,可以打开sliding menu // TOUCHMODE_MARGIN 边缘模式,在content页面中,如果想打开slding ,你需要在屏幕边缘滑动才可以打开slding menu // TOUCHMODE_NONE 自然是不能通过手势打开啦 sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN); // FragmentTransaction fragmentTransaction=getFragmentManager().beginTransaction(); // MenuFragment menuFragment = new MenuFragment(); // // fragmentTransaction.replace(R.id.menu, menuFragment); // fragmentTransaction.replace(R.id.content, new ContentFragment("Welcome"),"Welcome"); // fragmentTransaction.commit(); // // // getActionBar().setDisplayHomeAsUpEnabled(true); }
/** * gets the input from the user for enter new tasks we check here if user set any alarm for his * task or not in this method we update the list and the DB. */ private boolean createATaskAction() { // gets the text from the edittext view,and // validate the strings to be not empty, or with useless "white" chars setTitle(titleInputext.getText().toString().trim()); setDescription(descriptionInputText.getText().toString().trim()); // validate the string to be not empty, or with useless "white" chars if (getTaskTitle() != null && getTaskTitle().length() > 0) { // check if the notification checkbox is checked if (notifySwitch.isChecked() == true) { TimeFromPickers = myalarmmanager.getTimeFromPickers(datepicker, timepicker); setDifferenceInMillis(myalarmmanager.compareBetweenDates(TimeFromPickers)); boolean isLater = getDifferenceInMillis() != MyConstants.INVALID_TIME; // check if user choose an alarm for his task if (isLater == true) { setIntervalFromSpinner(); addANewTask(); myalarmmanager.setAlarm(taskDummy, getDifferenceInMillis(), getRepeatAlarmInterval()); return true; } else { TimeFromPickers = null; toastWithGravity("Invalid Time" + "\n" + "Turn Off Switch or Pick A different Time"); drawer.showMenu(false); } } // else, the task is without any Alarm else { addANewTask(); return true; } } // if edittext is empty, send toast to user else { toastWithGravity("First Fill The Text!"); } return false; }
private void configSlidingMenu(boolean phone) { SlidingMenu slidingMenu = getSlidingMenu(); slidingMenu.setShadowWidthRes(R.dimen.shadow_width); slidingMenu.setShadowDrawable(R.drawable.shadow_slidingmenu); if (phone) { slidingMenu.setBehindOffsetRes(R.dimen.slidingmenu_offset); } else { slidingMenu.setBehindOffset(Utility.getScreenWidth()); } slidingMenu.setFadeDegree(0.35f); slidingMenu.setOnPageScrollListener( new SlidingMenu.OnPageScrollListener() { @Override public void onPageScroll() { LongClickableLinkMovementMethod.getInstance().setLongClickable(false); (getFriendsTimeLineFragment()).clearActionMode(); (getFavFragment()).clearActionMode(); (getCommentsTimeLineFragment()).clearActionMode(); (getMentionsTimeLineFragment()).clearActionMode(); (getMyProfileFragment()).clearActionMode(); if (GlobalContext.getInstance().getAccountBean().isBlack_magic()) { (getSearchFragment()).clearActionMode(); (getDMFragment()).clearActionMode(); } } }); slidingMenu.setOnClosedListener( new SlidingMenu.OnClosedListener() { @Override public void onClosed() { LongClickableLinkMovementMethod.getInstance().setLongClickable(true); LocalBroadcastManager.getInstance(MainTimeLineActivity.this) .sendBroadcast(new Intent(AppEventAction.SLIDING_MENU_CLOSED_BROADCAST)); } }); }
@Override public void onCreate(Bundle savedInstanceState) { mFirstRun = savedInstanceState == null; // This line restore instance state when we are change theme and // activity restarts savedInstanceState = instanceState(savedInstanceState); super.onCreate(savedInstanceState); mCreatedByThemeManager = getIntent().getBooleanExtra(ThemeManager.KEY_CREATED_BY_THEME_MANAGER, false); if (mCreatedByThemeManager) { mFirstRun = false; } if (savedInstanceState != null) { mDisableMusic = savedInstanceState.getBoolean(KEY_DISABLE_MUSIC, false); mCurrentPage = savedInstanceState.getInt(KEY_PAGE, 0); } final ActionBar ab = getSupportActionBar(); ab.setTitle(R.string.library_name); setContentView(R.layout.content); final SlidingMenuA addonSM = requireSlidingMenu(); final SlidingMenu sm = addonSM.getSlidingMenu(); View menu = findViewById(R.id.menu); if (menu == null) { // Phone mStaticSlidingMenu = true; ab.setDisplayHomeAsUpEnabled(true); addonSM.setBehindContentView(makeMenuView(savedInstanceState)); addonSM.setSlidingActionBarEnabled(true); sm.setBehindWidth(computeMenuWidth()); sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN); sm.setSlidingEnabled(true); } else { // Tablet mStaticSlidingMenu = false; addonSM.setBehindContentView(new View(this)); // dummy view sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_NONE); sm.setSlidingEnabled(false); prepareMenuView(menu, savedInstanceState); } getSupportFragmentManager().addOnBackStackChangedListener(this); }
/** 进入编辑模式 */ public void toEdit() { editmodel = true; listAdapter.setEdit(true); noteListView.setAdapter(listAdapter); editTopLayout.setVisibility(View.VISIBLE); bottomLayout.setVisibility(View.VISIBLE); bottomLayout.startAnimation(AnimationUtils.loadAnimation(this, R.anim.push_bottom_in)); editTopLayout.startAnimation(AnimationUtils.loadAnimation(this, R.anim.push_top_in)); // 侧栏不可用 slidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_NONE); seeAllButton.setEnabled(false); // 侧栏按钮不可用 addNoteButton.setEnabled(false); // 添加按钮不可用 // 必定选择了一项,所以全部按钮都为可见 deleteButton.setVisibility(View.VISIBLE); shareButton.setVisibility(View.VISIBLE); moveButton.setVisibility(View.VISIBLE); lockedButton.setVisibility(View.VISIBLE); unlockedButton.setVisibility(View.VISIBLE); }
/** 回到正常选择模式 */ public void toNormal() { editmodel = false; listAdapter.setEdit(false); listAdapter.initMap(); noteListView.setAdapter(listAdapter); if (editTopLayout.getVisibility() == View.VISIBLE) { editTopLayout.setVisibility(View.GONE); bottomLayout.setVisibility(View.GONE); bottomLayout.startAnimation(AnimationUtils.loadAnimation(this, R.anim.push_bottom_out)); editTopLayout.startAnimation(AnimationUtils.loadAnimation(this, R.anim.push_top_out)); } if (searchTitle.getVisibility() == View.VISIBLE) { searchTitle.setVisibility(View.GONE); searchTitle.startAnimation(AnimationUtils.loadAnimation(this, R.anim.push_top_out)); } // 恢复侧栏可用 slidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN); seeAllButton.setEnabled(true); // 恢复侧栏按钮可用 addNoteButton.setEnabled(true); // 恢复添加按钮可用 }
/** * Further SlidingMenu initialization. Should be called within the activitiy's onPostCreate() * * @param savedInstanceState the saved instance state (unused) */ public void onPostCreate(Bundle savedInstanceState) { if (mViewBehind == null || mViewAbove == null) { throw new IllegalStateException( "Both setBehindContentView must be called " + "in onCreate in addition to setContentView."); } mOnPostCreateCalled = true; mSlidingMenu.attachToActivity( mActivity, mEnableSlide ? SlidingMenu.SLIDING_WINDOW : SlidingMenu.SLIDING_CONTENT); final boolean open; final boolean secondary; if (savedInstanceState != null) { open = savedInstanceState.getBoolean("SlidingActivityHelper.open"); secondary = savedInstanceState.getBoolean("SlidingActivityHelper.secondary"); } else { open = false; secondary = false; } new Handler() .post( new Runnable() { public void run() { if (open) { if (secondary) { mSlidingMenu.showSecondaryMenu(false); } else { mSlidingMenu.showMenu(false); } } else { mSlidingMenu.showContent(false); } } }); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // set the Behind View setBehindContentView(R.layout.act_sliding_menu_frame); FragmentTransaction t = this.getSupportFragmentManager().beginTransaction(); mFrag = new SampleListFragment(); t.replace(R.id.sliding_menu_frame, mFrag); t.commit(); // customize the SlidingMenu SlidingMenu sm = getSlidingMenu(); sm.setShadowWidthRes(R.dimen.shadow_width); sm.setShadowDrawable(R.drawable.shadow); sm.setBehindOffsetRes(R.dimen.slidingmenu_offset); sm.setFadeDegree(0.35f); sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN); }
protected void onCreate(Bundle savedInstanceState, int resLayout) { super.onCreate(savedInstanceState); supportsSDK = android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB; this.resLayout = resLayout; app = (TwitterListApplication) getApplication(); setUpViews(); getAPI(); onCreate(); if (requiresInternet) { if (app.getUserProfile() != null && !app.getAccessToken().equals("0")) { setUserUIControlsLoggedIn(app.getUserProfile()); onGettingUserInfo(app.getUserProfile()); } else if (!app.getAccessToken().equals("0")) { getUserInfo(); } else { if (!app.isStarted()) { menu.toggle(); } showErrorMessage(); } } app.setStarted(true); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); setTitle(getString(R.string.notification)); // 使actionbar上的logo可以点击 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { getSupportActionBar().setHomeButtonEnabled(true); getSupportActionBar() .setBackgroundDrawable(getResources().getDrawable(R.drawable.actionbar_bg)); } // set the Above View if (savedInstanceState != null) mContent = getSupportFragmentManager().getFragment(savedInstanceState, "mContent"); if (mContent == null) { mContent = new NotificationFragment(); } // set the Above View setContentView(R.layout.content_frame); getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, mContent).commit(); // set the Behind View setBehindContentView(R.layout.menu_frame); getSupportFragmentManager() .beginTransaction() .replace(R.id.menu_frame, new MenuFragment()) .commit(); // customize the SlidingMenu SlidingMenu sm = getSlidingMenu(); sm.setShadowWidthRes(R.dimen.shadow_width); sm.setShadowDrawable(R.drawable.shadow); sm.setBehindOffsetRes(R.dimen.slidingmenu_offset); sm.setFadeDegree(0.35f); sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN); // 设置menu动画 // setSlidingActionBarEnabled(true); // sm.setBehindScrollScale(0.0f); // sm.setBehindCanvasTransformer(mTransformer); }
@Override protected void onCreate(Bundle arg0) { // TODO Auto-generated method stub super.onCreate(arg0); setContentView(R.layout.calendar_activity); mGlobalData = (GlobalData) getApplicationContext(); this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); intiliazeTop(); intiliaze(); view = Calender.this.getLayoutInflater().inflate(R.layout.left_slide, null); menu = new SlidingMenu(this); menu.setMode(SlidingMenu.LEFT); menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN); menu.setBehindOffsetRes(R.dimen.sliding_limit); // menu.setFadeDegree(0.35f); menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN); menu.setMenu(view); menu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT); intilazeleft(view); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); init = false; ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); setBehindContentView(R.layout.menu_frame); getSupportFragmentManager() .beginTransaction() .replace(R.id.menu_frame, new MenuFragment()) .commit(); // customize the SlidingMenu SlidingMenu sm = getSlidingMenu(); sm.setShadowWidthRes(R.dimen.shadow_width); sm.setShadowDrawable(R.drawable.shadow); sm.setBehindOffsetRes(R.dimen.slidingmenu_offset); sm.setFadeDegree(0.35f); sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN); setContentView(R.layout.activity_main); downloadView = findViewById(R.id.DownloadView); progressBar = (ProgressBar) findViewById(R.id.ProgressBar); progressMessageTextView = (TextView) findViewById(R.id.ProgressTextView); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); boolean alwaysTurnOnScreen = preferences.getBoolean(getString(R.string.preference_always_turn_on_key), true); if (alwaysTurnOnScreen) { getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); } else { getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); } }
private void showUserProfile() { menu.toggle(); Intent I = new Intent(this, UserProfileActivity.class); startActivity(I); finish(); }