public void initialize() { this.drawerView = (ViewGroup) this.activity.findViewById(R.id.left_drawer); this.drawerLayout = (DrawerLayout) this.activity.findViewById(R.id.root_layout); this.drawerToggle = new ActionBarDrawerToggle(this.activity, this.drawerLayout, R.drawable.ic_drawer, R.string.app_name, R.string.app_name) { public void onDrawerClosed(View view) { TGDrawerManager.this.onVisibilityChanged(); } public void onDrawerOpened(View drawerView) { TGDrawerManager.this.onVisibilityChanged(); } }; this.drawerLayout.setDrawerListener(this.drawerToggle); this.appendListeners(); }
private void setUpNavigationDrawer() { mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close) { /** Called when a drawer has settled in a completely closed state. */ public void onDrawerClosed(View view) { super.onDrawerClosed(view); // getActionBar().setTitle(mTitle); } /** Called when a drawer has settled in a completely open state. */ public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); // getActionBar().setTitle(mDrawerTitle); } }; // Set the drawer toggle as the DrawerListener mDrawerLayout.setDrawerListener(mDrawerToggle); getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setHomeButtonEnabled(true); }
private void configureDrawer() { drawerLayout = (DrawerLayout) findViewById(R.id.drawer); actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.mipmap.ic_menu_closed, R.string.app_name, R.string.action_settings) { @Override public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); drawerView.bringToFront(); } }; drawerLayout.setDrawerListener(actionBarDrawerToggle); drawerLayout.setDrawerShadow(R.mipmap.drawer_shadow, GravityCompat.START); getActionBar().setHomeButtonEnabled(true); getActionBar().setDisplayHomeAsUpEnabled(true); ListView drawerList = (ListView) findViewById(R.id.drawer_list); drawerList.setAdapter(new DrawerListViewAdapter(this)); onDrawerItemSelected(); }
private void setActionBar() { // configure the action bar mActionBar = getSupportActionBar(); mActionBar.setDisplayShowHomeEnabled(true); mActionBar.setDisplayHomeAsUpEnabled(true); // configure the navigation drawer mDrawerList = (ExpandableListView) findViewById(R.id.left_drawer); mDrawerList.setOnChildClickListener(new DrawerItemClickListener()); mDrawerList.setOnGroupClickListener(new DrawerGroupItemClickListener()); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.about, R.string.about); mDrawerLayout.setDrawerListener(mDrawerToggle); }
@Override protected void onCreate(Bundle state) { super.onCreate(state); setContentView(R.layout.a_main); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.navigation_drawer_open, R.string.navigation_drawer_close); mDrawerLayout.setDrawerListener(mDrawerToggle); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); if (state == null) { getSupportFragmentManager().beginTransaction() .add(R.id.menu, new MenuFragment()) .commit(); mDrawerLayout.openDrawer(GravityCompat.START); } }
private void initViews() { mDrawerLayoutView = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerView = mDrawerLayoutView.findViewById(R.id.drawer); mDrawerSnapshotsView = mDrawerView.findViewById(R.id.snapshots); mDrawerSnapshotsView.setOnClickListener(this); mDrawerProfilesView = mDrawerView.findViewById(R.id.profiles); mDrawerProfilesView.setOnClickListener(this); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayoutView, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close); mDrawerLayoutView.setDrawerListener(new MyDrawerListener()); mDrawerLayoutView.openDrawer(mDrawerView); mSnapshotsListFrag.setMenuVisibility(false); // Sync the toggle state after onRestoreInstanceState has occurred. // The following line must be called, otherwise the provided drawer image will be used. mDrawerToggle.syncState(); }
@Override protected void onCreate( Bundle savedInstanceState ) { super.onCreate( savedInstanceState ); setContentView( R.layout.activity_nav_drawer ); dlNavDrawer = ( DrawerLayout ) findViewById( R.id.dl_nav_drawer ); drawerToggle = new ActionBarDrawerToggle( this, dlNavDrawer, R.drawable.ic_drawer, R.string.open_drawer_desc, R.string.close_drawer_desc ); dlNavDrawer.setDrawerListener( drawerToggle ); navDrawerPager = ( ViewPager ) findViewById( R.id.nav_drawer_pager ); navDrawerPagerIndicator = ( IconPagerIndicator ) findViewById( R.id.nav_drawer_pager_indicator ); navDrawerPagerAdapter = new NavDrawerPagerAdapter( getSupportFragmentManager() ); navDrawerPager.setAdapter( navDrawerPagerAdapter ); navDrawerPagerIndicator.setViewPager( navDrawerPager ); actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled( true ); actionBar.setHomeButtonEnabled( true ); }
private ActionBarDrawerToggle setupDrawerToggle() { return new ActionBarDrawerToggle(getActivity(), /* host Activity */ this, /* DrawerLayout object */ R.drawable.ic_navigation_drawer, /* nav drawer image to replace 'Up' caret */ R.string.drawer_open, /* "open drawer" description for accessibility */ R.string.drawer_close /* "close drawer" description for accessibility */ ) { public void onDrawerClosed(View view) { // setTitle(getCurrentTitle()); getActivity().invalidateOptionsMenu(); // call onPrepareOptionsMenu() } public void onDrawerOpened(View drawerView) { // setTitle("Navigate"); getActivity().invalidateOptionsMenu(); // call onPrepareOptionsMenu() } }; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.drawer_layout); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawer = (ListView) findViewById(R.id.left_drawer); mContent = (TextView) findViewById(R.id.content_text); mDrawerLayout.setDrawerListener(new DemoDrawerListener()); mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); mDrawer.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, Shakespeare.TITLES)); mDrawer.setOnItemClickListener(new DrawerItemClickListener()); mActionBar = createActionBarHelper(); mActionBar.init(); // ActionBarDrawerToggle provides convenient helpers for tying together the // prescribed interactions between a top-level sliding drawer and the action bar. mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close); }
/** * Create a ActionbarDrawerToggle to use. */ private ActionBarDrawerToggle getActionBarDrawerToggle() { return new ActionBarDrawerToggle( this, mDrawerLayout, R.drawable.ic_drawer, R.string.title_open, R.string.title_close) { public void onDrawerClosed(View view) { invalidateOptionsMenu(); mIsDrawerOpen = false; } public void onDrawerOpened(View drawerView) { invalidateOptionsMenu(); mIsDrawerOpen = true; } }; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close); mDrawerLayout.setDrawerListener(mDrawerToggle); getActionBar().setDisplayHomeAsUpEnabled(true); sectionTitles = getResources().getStringArray(R.array.fragment_names); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout); mDrawerList = (ListView) findViewById(R.id.left_drawer); mDrawerList.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_selectable_list_item, sectionTitles)); mDrawerList.setOnItemClickListener(this); selectItem(0); }
private void setNavigationDrawer() { mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close) { public void onDrawerClosed(View view) { super.onDrawerClosed(view); getSupportActionBar().setTitle(mTitle); invalidateOptionsMenu(); } public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); getSupportActionBar().setTitle(mDrawerTitle); invalidateOptionsMenu(); } }; mDrawerList.setAdapter(new NavigationDrawerAdapter(this, mDrawerTitles)); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); mDrawerLayout.setDrawerListener(mDrawerToggle); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); }
/** * Initialises the menu drawer. */ private void initMenuDrawer() { mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); if (mDrawerLayout == null) { return; } mLeftDrawer = findViewById(R.id.left_drawer); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, 0, 0); mDrawerLayout.setDrawerListener(mDrawerToggle); mActionBar.setDisplayHomeAsUpEnabled(true); mActionBar.setHomeButtonEnabled(true); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.drawer_layout); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawer = (ListView) findViewById(R.id.start_drawer); mContent = (TextView) findViewById(R.id.content_text); mDrawerLayout.setDrawerListener(new DemoDrawerListener()); mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); mDrawer.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, Shakespeare.TITLES)); mDrawer.setOnItemClickListener(new DrawerItemClickListener()); mActionBar = createActionBarHelper(); mActionBar.init(); // ActionBarDrawerToggle provides convenient helpers for tying together the // prescribed interactions between a top-level sliding drawer and the action bar. mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close); }
@Override public boolean onCreate(Bundle savedState) { initializeActionBar(); // Allow shortcut keys to function for the ActionBar and menus. mActivity.setDefaultKeyMode(Activity.DEFAULT_KEYS_SHORTCUT); // The "open drawer description" argument is for when the drawer is // open, so tell the user that interaction will cause the drawer to // close and vice versa for the "close drawer description" argument. mDrawerToggle = new ActionBarDrawerToggle((Activity) mActivity, mDrawerContainer, R.drawable.ic_drawer, R.string.drawer_close, R.string.drawer_open); mDrawerListener = new ReaderDrawerListener(); mDrawerContainer.setDrawerListener(mDrawerListener); mDrawerContainer.setDrawerShadow( mContext.getResources().getDrawable(R.drawable.drawer_shadow), Gravity.START); mDrawerToggle.setDrawerIndicatorEnabled(true); return true; }
private ActionBarDrawerToggle createDrawerToggleListener() { return new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close) { public void onDrawerClosed(View view) { mActionBar.setTitle(getString(R.string.app_name)); super.onDrawerClosed(view); } public void onDrawerOpened(View drawerView) { // Set the title on the action when drawer open mActionBar.setTitle("Title"); super.onDrawerOpened(drawerView); } }; }
@Override protected void initLayout() { mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerLayout.setDrawerListener(new MyDrawerListener()); mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close); // init the action bar to Display mActionBar = getActionBar(); mActionBar.setDisplayHomeAsUpEnabled(true); mActionBar.setHomeButtonEnabled(true); setActionBarTitle(DafaultTitle); manager.beginTransaction().add(R.id.container, new About(), "About") .commit(); manager.beginTransaction().add(R.id.left_container, new DrawerMain(),"DrawerMain").commit(); }
@Override protected void initLayout() { mDrawerLayout.setDrawerListener(new MyDrawerListener()); mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.lm_ic_drawer_white, R.string.drawer_open, R.string.drawer_close); // init the actionbar to Display mActionBar = getActionBar(); // 决定左上角是否可以点击 mActionBar.setDisplayHomeAsUpEnabled(true); setActionBarTitle(DefaultTitle); manager.beginTransaction() .add(R.id.container, new MeetlistFm(), "LMList_fm").commit(); manager.beginTransaction() .add(R.id.left_container, new DrawerMain(), "DrawerMain") .commit(); }
private ActionBarDrawerToggle setupDrawerToggle() { return new ActionBarDrawerToggle(getActivity(), /* host Activity */ this, /* DrawerLayout object */ R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */ R.string.drawer_open, /* "open drawer" description for accessibility */ R.string.drawer_close /* "close drawer" description for accessibility */ ) { public void onDrawerClosed(View view) { // setTitle(getCurrentTitle()); // call onPrepareOptionsMenu() getActivity().supportInvalidateOptionsMenu(); } public void onDrawerOpened(View drawerView) { // setTitle("Navigate"); // call onPrepareOptionsMenu() getActivity().supportInvalidateOptionsMenu(); } }; }
private void initNavigationDrawer() { mDrawerLayout = (DrawerLayout) findViewById(R.id.mainact_drawerlayout); mDrawerListView = (ListView) findViewById(R.id.listview_drawer); mDrawerContent = getResources().getStringArray(R.array.drawer_items); mDrawerListView.setAdapter(new DrawerListAdapter(this, mDrawerContent)); mDrawerListView.setOnItemClickListener(new DrawerItemClickListenerZ()); // Allow toggling navigation drawer via app icon if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.open_drawer, R.string.close_drawer); mDrawerLayout.setDrawerListener(mDrawerToggle); getActionBar().setDisplayHomeAsUpEnabled(true); } }
private void setDrawer() { mDrawerItems = this.getResources().getStringArray(R.array.drawer_item); mDrawerList.setAdapter(new DrawerListAdapter(this, Lists .newArrayList(mDrawerItems))); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open_e, R.string.drawer_close_e) { public void onDrawerClosed(View view) { super.onDrawerClosed(view); invalidateOptionsMenu(); } public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); invalidateOptionsMenu(); } }; mDrawerLayout.setDrawerListener(mDrawerToggle); }
public static SubjectFactory<ActionBarDrawerToggleSubject, ActionBarDrawerToggle> type() { return new SubjectFactory<ActionBarDrawerToggleSubject, ActionBarDrawerToggle>() { @Override public ActionBarDrawerToggleSubject getSubject(FailureStrategy fs, ActionBarDrawerToggle that) { return new ActionBarDrawerToggleSubject(fs, that); } }; }
public void onCreateDrawer() { try { drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); drawerToggle = new ActionBarDrawerToggle((Activity) this, drawerLayout, R.drawable.ic_menu_white_24dp, 0, 0) { public void onDrawerClosed(View view) { getActionBar().setTitle(R.string.label_menu); } public void onDrawerOpened(View drawerView) { getActionBar().setTitle("Navigation"); } }; drawerLayout.setDrawerListener(drawerToggle); getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setHomeButtonEnabled(true); drawerList = (ListView) findViewById(R.id.left_drawer); drawerList.setAdapter(new NavItemAdapter(this, layers, resources)); //drawerList.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_list_item, R.id.drawer_item_textView, // layers)); //View footerView = ((LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate( // R.layout.drawer_list_footer, null, false); //drawerList.addFooterView(footerView); drawerList.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int pos, long arg3) { openActivityForPos(pos); } }); } catch (Exception e) { // Activity has no drawer e.printStackTrace(); } }
@Override protected void onCreate(Bundle savedInstanceState) { Log.d(LOG_TAG, "onCreate"); super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); MobileAds.initialize(getApplicationContext(), getString(R.string.banner_ad_app_id)); AdView mAdView = (AdView) findViewById(R.id.adView); // Just for testing AdRequest request = new AdRequest.Builder() .addTestDevice(AdRequest.DEVICE_ID_EMULATOR) // All emulators .addTestDevice("AC98C820A50B4AD8A2106EDE96FB87D4") // An example device ID .build(); mAdView.loadAd(request); if (savedInstanceState == null) { homeFragment = HomeFragment.getInstance(); getSupportFragmentManager().beginTransaction() .replace(R.id.content_fl, homeFragment) .commit(); } mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_hamburger, R.string.drawer_open, R.string.drawer_close); mDrawerLayout.setDrawerListener(mDrawerToggle); NavigationView mNavigationView = (NavigationView) findViewById(R.id.nav_view); setupDrawerContent(mNavigationView); DealHuntingSyncAdapter.initializeSyncAdapter(this); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_activity); /*Setup the NavigationDrawer and the ActionBar*/ mTitle=mDrawerTitle = getTitle(); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); initNavigationDrawer(); getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setHomeButtonEnabled(true); mDrawerToggle = new ActionBarDrawerToggle( this, /* host Activity */ mDrawerLayout, /* DrawerLayout object */ R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */ R.string.navigation_drawer_open, /* "open drawer" description for accessibility */ R.string.navigation_drawer_close /* "close drawer" description for accessibility */ ) { public void onDrawerClosed(View view) { getActionBar().setTitle(mTitle); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } public void onDrawerOpened(View drawerView) { getActionBar().setTitle(mDrawerTitle); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } }; mDrawerLayout.setDrawerListener(mDrawerToggle); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (userService.getMe() == null) { activityStarter.startLogin(this); return; } setContentView(R.layout.event_details); drawerToggle = new ActionBarDrawerToggle( this, drawerLayout, R.drawable.ic_drawer, R.string.nav_drawer_open_desc, R.string.nav_drawer_close_desc ) { public void onDrawerClosed(View view) { if (newEvent != null) { activityStarter.startEventDetails(EventDetails.this, newEvent, false); newEvent = null; } invalidateOptionsMenu(); } public void onDrawerOpened(View drawerView) { invalidateOptionsMenu(); } }; setupMenuActions(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.components_view); Injector.inject(this); ButterKnife.inject(this); if (savedInstanceState == null) { getFragmentManager().beginTransaction() .add(R.id.fragmentPlaceholder, new ComponentsFragment(), "blur").commit(); } drawerLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.START); actionBarDrawerToggle = new ActionBarDrawerToggle( this, /* host Activity */ drawerLayout, /* DrawerLayout object */ R.drawable.ic_drawer, /* nav drawer icon to replace 'Up' caret */ R.string.drawer_open, /* "open drawer" description */ R.string.drawer_close /* "close drawer" description */ ) { public void onDrawerClosed(View view) { getActionBar().setTitle(ComponentsActivity.this.getTitle()); } public void onDrawerOpened(View drawerView) { getActionBar().setTitle(ComponentsActivity.this.getTitle()); } }; drawerLayout.setDrawerListener(actionBarDrawerToggle); getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setHomeButtonEnabled(true); actionBarDrawerToggle.syncState(); }
@Override protected void onCreate(Bundle savedInstanceStateMain) { super.onCreate(savedInstanceStateMain); setContentView(R.layout.activity_main); spmaster = getSharedPreferences("mysp",0); initializer(); mTitle = mDrawerTitle = getTitle(); enableService(); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setHomeButtonEnabled(true); mDrawerToggle = new ActionBarDrawerToggle( this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close ) { public void onDrawerClosed(View view) { getActionBar().setTitle(mTitle); invalidateOptionsMenu(); } public void onDrawerOpened(View drawerView) { getActionBar().setTitle(mDrawerTitle); invalidateOptionsMenu(); } }; mDrawerLayout.setDrawerListener(mDrawerToggle); if(savedInstanceStateMain == null) { navigateTo(1); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.drawer_layout); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawer = (ListView) findViewById(R.id.start_drawer); contentListView = (ListView) findViewById(R.id.activity_googlecards_listview); mDrawerLayout.setDrawerListener(new DemoDrawerListener()); mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); mDrawer.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_layout_item, Constant.TITLES)); mDrawer.setOnItemClickListener(new DrawerItemClickListener()); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close); bottonInAdapter = new ListViewAdapter(this); bottonInAdapter.addAll(getItems()); animationAdapter = new SwingBottomInAnimationAdapter(bottonInAdapter); animationAdapter.setAbsListView(contentListView); contentListView.setAdapter(animationAdapter); }
private void createDrawerMenu() { // Get layout drawer mLayoutDrawer = (RelativeLayout) findViewById(R.id.drawerContainer); // Set drawer Layout mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); // Configurate Drawer toggle mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, android.R.string.ok, android.R.string.cancel) { /** Called when a drawer has settled in a completely closed state. */ public void onDrawerClosed(View view) { super.onDrawerClosed(view); getSupportActionBar().setTitle(mTitle); ActivityCompat.invalidateOptionsMenu(ColourioActivity.this); } /** Called when a drawer has settled in a completely open state. */ public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); getSupportActionBar().setTitle(mTitle); ActivityCompat.invalidateOptionsMenu(ColourioActivity.this); } }; mDrawerLayout.setDrawerListener(mDrawerToggle); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_beats_music); actionBarTitle = drawerTitle = getTitle(); navTiles = getResources().getStringArray(R.array.nav_tiles); drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); drawerList = (ListView) findViewById(R.id.left_drawer); drawerList.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_list_item, navTiles)); drawerList.setOnItemClickListener(new DrawerItemClickListener()); getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setHomeButtonEnabled(true); drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.drawable.beatsmusic_full_color, R.string.drawer_open, R.string.drawer_close) { public void onDrawerClosed(View view) { getActionBar().setTitle(drawerTitle); invalidateOptionsMenu(); } public void onDrawerOpened(View drawerView) { getActionBar().setTitle(drawerTitle); invalidateOptionsMenu(); } }; drawerLayout.setDrawerListener(drawerToggle); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_homescreen); drawertitles = getResources().getStringArray(R.array.menutiems); drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); drawerList = (ListView) findViewById(R.id.left_drawer); drawerList.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, drawertitles)); drawerList.setOnItemClickListener(new DrawerItemClickListener()); toggle = new ActionBarDrawerToggle(this, drawerLayout, R.drawable.ic_drawer, R.string.opendrawer, R.string.app_name); manager = getFragmentManager(); fragmentTransaction = manager.beginTransaction(); frag = new HomeFragment(); fragmentTransaction.replace(R.id.content_frame, frag).addToBackStack(null); fragmentTransaction.commit(); drawerLayout.setDrawerListener(toggle); drawerLayout.post(new Runnable() { @Override public void run() { toggle.syncState(); } }); Toolbar toolbar = (Toolbar)findViewById(R.id.toolbar); toolbar.setNavigationIcon(R.drawable.ic_drawer); //setup the navigation drawer setSupportActionBar(toolbar); getSupportActionBar().setDisplayShowHomeEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); toggle.setDrawerIndicatorEnabled(true); }
private void auxOnStart(){ //MOSTRAR EL MENU if(this.hasmenu == true){ new MenuSettings(this).show(); } getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE); getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setDisplayShowTitleEnabled(true); this.maindrawer = (DrawerLayout)findViewById(R.id.drawer_layout); drawerList = (ListView) findViewById(R.id.left_drawer); drawerToggle = new ActionBarDrawerToggle( this, maindrawer,R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close ) { public void onDrawerClosed(View view) { getActionBar().setTitle(planets[_POS].getName()); invalidateOptionsMenu(); } public void onDrawerOpened(View drawerView) { getActionBar().setTitle(R.string.drawer_open); invalidateOptionsMenu(); } }; }
private void setupNavigationDrawer() { final ActionBar actionBar = getActionBar(); drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.drawable.ic_drawer, R.string.navigation_drawer_open, R.string.navigation_drawer_close) { /** Called when a drawer has settled in a completely closed state. */ public void onDrawerClosed(View view) { super.onDrawerClosed(view); //noinspection ConstantConditions actionBar.setTitle(getString(R.string.app_name)); // TODO invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } /** Called when a drawer has settled in a completely open state. */ public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); //noinspection ConstantConditions actionBar.setTitle(getString(R.string.app_name)); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } }; drawerLayout.setDrawerListener(drawerToggle); drawerLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.START); drawerToggle.setDrawerIndicatorEnabled(navDrawerEnable); drawerLayout.setDrawerLockMode( navDrawerEnable ? DrawerLayout.LOCK_MODE_UNLOCKED : DrawerLayout.LOCK_MODE_LOCKED_CLOSED); // Display nav drawer if it's the first time the app is opened per Google's guidelines if (!seenNavDrawer.get()) { drawerLayout.postDelayed(() -> { drawerLayout.openDrawer(Gravity.START); Toast.makeText(MainActivity.this, R.string.drawer_intro_text, LENGTH_LONG).show(); }, TimeUnit.MILLISECONDS.toMillis(500)); /* Half a second, but there's gotta be a better way*/ seenNavDrawer.set(true); } }
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);// TODO testLockScreen(); init(); initView(); initData(); customActionBar(); if (getSupportFragmentManager().findFragmentById(R.id.frame_left_container) == null) { getSupportFragmentManager().beginTransaction() .add(R.id.frame_left_container, LeftFragment.newInstance()).commit(); } if (getSupportFragmentManager().findFragmentById(R.id.frame_right_container) == null) { getSupportFragmentManager().beginTransaction() .add(R.id.frame_right_container, RightFragment.newInstance()).commit(); } if (getSupportFragmentManager().findFragmentById(R.id.frame_container) == null) { getSupportFragmentManager().beginTransaction().add(R.id.frame_container, mMainFragment) .commit(); } mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.app_name, R.string.app_name); mDrawerLayout.setDrawerListener(mDrawerToggle); }
private void initNavigationDrawer() { mMenuDrawer = findViewById(R.id.left_drawer); mNavigationMenu = new NavigationMenu(this, mMenuDrawer); mNavigationMenuManager = new NavigationMenuManager(this); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.vtulife_ic_navigation_drawer, R.string.navigation_drawer_open, R.string.navigation_drawer_close) { public void onDrawerClosed(View view) { super.onDrawerClosed(view); getSupportActionBar().setTitle(R.string.app_name); supportInvalidateOptionsMenu(); } public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); getSupportActionBar().setTitle(R.string.menu); supportInvalidateOptionsMenu(); } }; mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); mDrawerLayout.setDrawerListener(mDrawerToggle); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); mDrawerLayout.openDrawer(mMenuDrawer); }
private void setNavigationDrawer() { dlDrawer = (DrawerLayout) findViewById(R.id.dl_activity_main_drawer); dtToggle = new ActionBarDrawerToggle(this, dlDrawer, R.drawable.ic_drawer, R.string.open_drawer, R.string.close_drawer) { }; dlDrawer.setDrawerListener(dtToggle); getActionBar().setDisplayHomeAsUpEnabled(true); }
private void initNavigationDrawer() { //Log.d(TAG, "initNavigationDrawer"); if (mDrawerLayout == null || mDrawerList == null) { //Get views mDrawerLayout = (DrawerLayout) this.findViewById(R.id.drawer_layout); mDrawerList = (ExpandableListView) this.findViewById(R.id.left_drawer); //Set onClickListeners mDrawerList.setOnGroupClickListener(new DrawerItemClickListener(this, mDrawerLayout, mDrawerList)); mDrawerList.setOnChildClickListener(new DrawerItemClickListener(this, mDrawerLayout, mDrawerList)); //NavDrawer Initialization mAdapter = new ExpandableDrawerAdapter(this, mMapState.getDrawerItems()); mDrawerList.setAdapter(mAdapter); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close) { public void onDrawerClosed(View view) { super.onDrawerClosed(view); } public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); mAdapter.notifyDataSetInvalidated(); } }; mDrawerLayout.setDrawerListener(mDrawerToggle); mDrawerList.setDividerHeight(0); mDrawerList.setBackgroundColor(Color.WHITE); mDrawerToggle.syncState(); //Enable and show navigation drawer icon try { getActionBar().setDisplayHomeAsUpEnabled(true); }catch (NullPointerException e){ e.printStackTrace(); } getActionBar().setHomeButtonEnabled(true); } }
/** * drawer 的初始化方法 */ private void creatdrawer() { // TODO 生成抽屉方法开始 mTitle = mDrawerTitle = getTitle(); mHomeTitles = getResources().getStringArray(R.array.home_array); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.left_drawer); // set a custom shadow that overlays the main content when the drawer opens mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); // set up the drawer's list view with items and click listener mDrawerList.setAdapter(new ArrayAdapter<String>(this,R.layout.drawer_list_item,mHomeTitles)); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); // enable ActionBar app icon to behave as action to toggle nav drawer mActionBar.setDisplayHomeAsUpEnabled(true); mActionBar.setHomeButtonEnabled(true); // ActionBarDrawerToggle ties together the the proper interactions // between the sliding drawer and the action bar app icon mDrawerToggle = new ActionBarDrawerToggle( this, /* host Activity */ mDrawerLayout, /* DrawerLayout object */ R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */ R.string.drawer_open, /* "open drawer" description for accessibility */ R.string.drawer_close /* "close drawer" description for accessibility */ ) { public void onDrawerClosed(View view) { mActionBar.setTitle(mTitle); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() 此时关闭抽屉 } public void onDrawerOpened(View drawerView) { mActionBar.setTitle(mDrawerTitle); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() 此时打开抽屉 View v=mDrawerList.getChildAt(position); v.setBackgroundColor(Color.GRAY); } }; mDrawerLayout.setDrawerListener(mDrawerToggle); }
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ButterKnife.inject(this); initActionBar(); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close); mDrawerLayout.setDrawerListener(mDrawerToggle); setCategory(Utils.FORUM_CATEGORY[0]); UpdateChecker.checkForNotification(MainActivity.this); replaceFragment(R.id.left_drawer, new DrawerFragment()); }