@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()); }
@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); }
@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); // 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); }
@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 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 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) { 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 setUpViews() { setContentView(R.layout.activity_base_assembly); activityContentLayout = (LinearLayout) findViewById(R.id.activity_content); errorMessageView = (TextView) findViewById(R.id.error_not_logged_in); menu = new SlidingMenu(this); 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.setFadeDegree(0.35f); menu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT); menu.setMenu(R.layout.slidebar); mInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); mInflater.inflate(resLayout, activityContentLayout); menuAdapter = new MenuListAdapter(this); menuListView = (ListView) findViewById(R.id.sidebar_list); menuListView.setAdapter(menuAdapter); menuListView.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { MenuListItem item = (MenuListItem) arg1; item.getItem().getAction().run(); } }); menuListView.setOnItemLongClickListener( new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> arg0, View view, int arg2, long arg3) { MenuListItem item = (MenuListItem) view; OnLongClickListener longClickAction = item.getItem().getLongClickAction(); if (longClickAction != null) { item.getItem().getLongClickAction().onLongClick(view); } return true; } }); loginItem = menuAdapter.getLoginItem(); loginItem.setAction( new Runnable() { @Override public void run() { if (loggedIn) { showUserProfile(); } else { authorizeUser(); } } }); loginItem.setLongClickAction( new OnLongClickListener() { @SuppressLint("NewApi") @Override public boolean onLongClick(View view) { if (loggedIn) { if (app.isSupportsHoneyComb()) { showProfilePopup(view); } else { showProfileDialog(); } return true; } else { return false; } } }); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (Utils.isWide(this)) { // wide enough, switch to tablet layout final Intent intent = new Intent(); intent.setClass(this, TabletActivity.class); startActivity(intent); finish(); return; } mPrefs = getPreferences(MODE_PRIVATE); mMenu = getSlidingMenu(); mMenu.setMode(SlidingMenu.LEFT_RIGHT); mMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN); mMenu.setBehindOffset((int) getResources().getDimension(R.dimen.sliding_menu_offset)); mMenu.setFadeDegree(0.5f); mMenu.setShadowWidthRes(R.dimen.sliding_menu_shadow); mMenu.setShadowDrawable(R.drawable.shadow_left); mMenu.setSecondaryShadowDrawable(R.drawable.shadow_right); // activity content setContentView(R.layout.activity_phone); mContainerVcard = findViewById(R.id.container_vcard); mVerticalLeft = findViewById(R.id.vertical_left); mVerticalRight = findViewById(R.id.vertical_right); mHintLeft = findViewById(R.id.side_hint_left); mHintRight = findViewById(R.id.side_hint_right); setBehindContentView(R.layout.menu_primary); mMenu.setSecondaryMenu(R.layout.menu_secondary); if (savedInstanceState == null) { // vcard getSupportFragmentManager() .beginTransaction() .replace(R.id.container_vcard, new VcardFragment()) .commit(); /* * displaying of layout waits until onCreate completes * load another fragments little bit later to allow fast displaying of activity_phone one */ sHandler.postDelayed( new Runnable() { @Override public void run() { // networks getSupportFragmentManager() .beginTransaction() .replace(R.id.container_networks, new NetworksFragment()) .commit(); // timeline getSupportFragmentManager() .beginTransaction() .replace(R.id.container_timeline, new TimelineFragment()) .commit(); } }, 250); } mMenu.setOnOpenedListener( new SlidingMenu.OnOpenedListener() { @Override public void onOpened() { if (mAnimVcardOut.isRunning()) { mAnimVcardOut.end(); } mAnimVcardOut.setTarget(mContainerVcard); mAnimVcardOut.start(); if (mMenu.isSecondaryMenuShowing()) { if (mAnimVerticalRightIn.isRunning()) { mAnimVerticalRightIn.end(); } mAnimVerticalRightIn.setTarget(mVerticalRight); mAnimVerticalRightIn.start(); } else { if (mAnimVerticalLeftIn.isRunning()) { mAnimVerticalLeftIn.end(); } mAnimVerticalLeftIn.setTarget(mVerticalLeft); mAnimVerticalLeftIn.start(); } final SharedPreferences.Editor edit = mPrefs.edit(); edit.putBoolean(Constants.PREF_SIDE_USED, true); edit.commit(); if (mTracker != null) { mTracker.sendEvent("activity_phone", "open", "slide_menu", 0l); GAServiceManager.getInstance().dispatch(); } } }); mMenu.setOnClosingListener( new SlidingMenu.OnClosingListener() { @Override public void onClosing() { if (mVerticalLeft.getVisibility() == View.VISIBLE) { if (mAnimVerticalLeftIn.isRunning()) { mAnimVerticalLeftIn.end(); } mVerticalLeft.setVisibility(View.INVISIBLE); } else if (mVerticalRight.getVisibility() == View.VISIBLE) { if (mAnimVerticalRightIn.isRunning()) { mAnimVerticalRightIn.end(); } mVerticalRight.setVisibility(View.INVISIBLE); } if (mAnimVcardOut.isRunning()) { mAnimVcardOut.end(); } mContainerVcard.setAlpha(1.0f); // TODO: level 11+ mContainerVcard.setVisibility(View.VISIBLE); } }); }