當前位置: 首頁>>代碼示例>>Java>>正文


Java ActionBarDrawerToggle類代碼示例

本文整理匯總了Java中android.support.v4.app.ActionBarDrawerToggle的典型用法代碼示例。如果您正苦於以下問題:Java ActionBarDrawerToggle類的具體用法?Java ActionBarDrawerToggle怎麽用?Java ActionBarDrawerToggle使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ActionBarDrawerToggle類屬於android.support.v4.app包,在下文中一共展示了ActionBarDrawerToggle類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initialize

import android.support.v4.app.ActionBarDrawerToggle; //導入依賴的package包/類
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();
}
 
開發者ID:theokyr,項目名稱:TuxGuitar-1.3.1-fork,代碼行數:18,代碼來源:TGDrawerManager.java

示例2: setUpNavigationDrawer

import android.support.v4.app.ActionBarDrawerToggle; //導入依賴的package包/類
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);
   
}
 
開發者ID:safesoftware,項目名稱:fme-apps-android,代碼行數:25,代碼來源:MainActivity.java

示例3: configureDrawer

import android.support.v4.app.ActionBarDrawerToggle; //導入依賴的package包/類
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();
}
 
開發者ID:ajitsing,項目名稱:ExpenseManager,代碼行數:21,代碼來源:MainActivity.java

示例4: setActionBar

import android.support.v4.app.ActionBarDrawerToggle; //導入依賴的package包/類
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);
}
 
開發者ID:emuneee,項目名稱:nc-traffic-cams-open,代碼行數:18,代碼來源:MainActivity.java

示例5: onCreate

import android.support.v4.app.ActionBarDrawerToggle; //導入依賴的package包/類
@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);
    }
}
 
開發者ID:yinghuihong,項目名稱:fonticon,代碼行數:21,代碼來源:MainActivity.java

示例6: initViews

import android.support.v4.app.ActionBarDrawerToggle; //導入依賴的package包/類
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();
}
 
開發者ID:yongce,項目名稱:AppTrafficAnalyzer,代碼行數:20,代碼來源:LauncherActivity.java

示例7: onCreate

import android.support.v4.app.ActionBarDrawerToggle; //導入依賴的package包/類
@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 );
}
 
開發者ID:iTwenty,項目名稱:Hashtagger,代碼行數:27,代碼來源:NavDrawerActivity.java

示例8: setupDrawerToggle

import android.support.v4.app.ActionBarDrawerToggle; //導入依賴的package包/類
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()
		}
	};
}
 
開發者ID:MainMethod1,項目名稱:TrailMix-for-peel-android,代碼行數:19,代碼來源:FragmentNavigationDrawer.java

示例9: onCreate

import android.support.v4.app.ActionBarDrawerToggle; //導入依賴的package包/類
@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);
}
 
開發者ID:reknih,項目名稱:informant-droid,代碼行數:26,代碼來源:DrawerLayoutActivity.java

示例10: getActionBarDrawerToggle

import android.support.v4.app.ActionBarDrawerToggle; //導入依賴的package包/類
/**
 * 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;
        }
    };
}
 
開發者ID:mbeloded,項目名稱:oidarSample,代碼行數:23,代碼來源:MainActivity.java

示例11: onCreate

import android.support.v4.app.ActionBarDrawerToggle; //導入依賴的package包/類
@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);
}
 
開發者ID:JorgeCastilloPrz,項目名稱:ExpandablePanel,代碼行數:21,代碼來源:MainActivity.java

示例12: setNavigationDrawer

import android.support.v4.app.ActionBarDrawerToggle; //導入依賴的package包/類
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);
}
 
開發者ID:levibostian,項目名稱:PantryPirate,代碼行數:24,代碼來源:MainActivity.java

示例13: initMenuDrawer

import android.support.v4.app.ActionBarDrawerToggle; //導入依賴的package包/類
/**
 * 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);
}
 
開發者ID:bbqsrc,項目名稱:robust-android,代碼行數:20,代碼來源:MainActivity.java

示例14: onCreate

import android.support.v4.app.ActionBarDrawerToggle; //導入依賴的package包/類
@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);
}
 
開發者ID:benhysell,項目名稱:V.FlyoutTest,代碼行數:26,代碼來源:DrawerLayoutActivity.java

示例15: onCreate

import android.support.v4.app.ActionBarDrawerToggle; //導入依賴的package包/類
@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;
}
 
開發者ID:george-zhang-work,項目名稱:dove,代碼行數:19,代碼來源:AbstractActivityController.java


注:本文中的android.support.v4.app.ActionBarDrawerToggle類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。