当前位置: 首页>>代码示例>>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;未经允许,请勿转载。