当前位置: 首页>>代码示例>>Java>>正文


Java ActionBarDrawerToggle类代码示例

本文整理汇总了Java中android.support.v7.app.ActionBarDrawerToggle的典型用法代码示例。如果您正苦于以下问题:Java ActionBarDrawerToggle类的具体用法?Java ActionBarDrawerToggle怎么用?Java ActionBarDrawerToggle使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ActionBarDrawerToggle类属于android.support.v7.app包,在下文中一共展示了ActionBarDrawerToggle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreate

import android.support.v7.app.ActionBarDrawerToggle; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_flex_box_layout);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open,
            R.string.navigation_drawer_close);
    if (drawer != null) {
        drawer.addDrawerListener(toggle);
    }
    toggle.syncState();

    initNavigation();
    initListener();
}
 
开发者ID:Pingsh,项目名称:Mix,代码行数:20,代码来源:MainActivity.java

示例2: initializeDrawer

import android.support.v7.app.ActionBarDrawerToggle; //导入依赖的package包/类
private void initializeDrawer() {
	mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout);
	ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
			this, mDrawer, mToolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
	mDrawer.addDrawerListener(toggle);
	toggle.syncState();

	mNavigationView = (NavigationView) findViewById(R.id.nav_view);
	mNavigationView.setNavigationItemSelectedListener(this);

	// Version
	TextView appVersion = (TextView) mNavigationView.getHeaderView(0).findViewById(R.id.app_version);
	appVersion.setText(getString(R.string.about_version,
			Utils.getVersionName(this),
			Integer.toString(Utils.getVersionCode(this))));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:MainActivity.java

示例3: prepareDrawerToggle

import android.support.v7.app.ActionBarDrawerToggle; //导入依赖的package包/类
private void prepareDrawerToggle() {
    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.drawer_open, R.string.drawer_close) {
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            getSupportActionBar().setTitle(mActivityTitle);
            invalidateOptionsMenu();
        }

        public void onDrawerClosed(View view) {
            super.onDrawerClosed(view);
            getSupportActionBar().setTitle(mActivityTitle);
            invalidateOptionsMenu();
        }
    };

    mDrawerToggle.setDrawerIndicatorEnabled(true);
    mDrawerLayout.setDrawerListener(mDrawerToggle);
}
 
开发者ID:dandanes7,项目名称:lurkerhn,代码行数:19,代码来源:MainActivity.java

示例4: onCreate

import android.support.v7.app.ActionBarDrawerToggle; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
  setSupportActionBar(toolbar);

  DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
  ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
      this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
  drawer.setDrawerListener(toggle);
  toggle.syncState();

  NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
  navigationView.setNavigationItemSelectedListener(this);

  if (savedInstanceState == null) {
    int selectedItem = PreferenceManager.getDefaultSharedPreferences(this).getInt(
        KEY_SELECTED_NAVDRAWER_ITEM_ID,
        INITIAL_NAVDRAWER_ITEM_ID);
    handleNavigationItemClick(selectedItem);
    navigationView.setCheckedItem(selectedItem);
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:MainActivity.java

示例5: onCreate

import android.support.v7.app.ActionBarDrawerToggle; //导入依赖的package包/类
@Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        navigationView = (NavigationView) findViewById(R.id.nav_view);
        navigationView.setNavigationItemSelectedListener(this);

        drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);

        ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
        drawerLayout.setDrawerListener(toggle);
        toggle.syncState();

        slidingUpPanelLayout = (SlidingUpPanelLayout) findViewById(R.id.sliding_layout);

//        logAdapter = new LogAdapter(this);
//        mLogger = (RecyclerView) findViewById(R.id.rc_logger);
//        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
//        linearLayoutManager.setStackFromEnd(true);
//        mLogger.setHasFixedSize(true);
//        mLogger.setAdapter(logAdapter);
    }
 
开发者ID:tranleduy2000,项目名称:sortalgorithm,代码行数:27,代码来源:MainActivity.java

示例6: onCreate

import android.support.v7.app.ActionBarDrawerToggle; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    drawerAdapter = new DrawerAdapter(this, this);
    RecyclerView drawerRecycler = (RecyclerView) findViewById(R.id.nav_view);
    drawerRecycler.setAdapter(drawerAdapter);
    drawerRecycler.setLayoutManager(new LinearLayoutManager(this));

    if (savedInstanceState == null) {
        getSupportFragmentManager().beginTransaction()
                .replace(R.id.fragmentContainer, new MainFragment(), "Fragment")
                .commit();
    }
    tieneDosFragments = findViewById(R.id.contentFrame) != null;
    updateDrawer();
}
 
开发者ID:UTN-FRBA-Mobile,项目名称:Clases-2017c1,代码行数:27,代码来源:MainActivity.java

示例7: onCreate

import android.support.v7.app.ActionBarDrawerToggle; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    setTab(R.id.nav_ind_tutoring, R.string.ind_tutoring, IndTutoringFragment.newInstance());

    // // TODO: 11/26/2016 add welcome dialog
}
 
开发者ID:tonyzhang617,项目名称:tutoriah,代码行数:21,代码来源:MainActivity.java

示例8: onCreate

import android.support.v7.app.ActionBarDrawerToggle; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    NavigationView navigationView = findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    navigationView.bringToFront();
    navigationView.requestLayout();

    DrawerLayout drawer = findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.addDrawerListener(toggle);
    toggle.setDrawerIndicatorEnabled(true);
    toggle.syncState();
}
 
开发者ID:barnhill,项目名称:SimpleBible,代码行数:20,代码来源:MainActivity.java

示例9: onCreate

import android.support.v7.app.ActionBarDrawerToggle; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);

    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.main_drawer_open, R.string.main_drawer_close);
    mDrawerToggle.setDrawerIndicatorEnabled(true);
    mDrawerLayout.setDrawerListener(mDrawerToggle);

    if (savedInstanceState == null) {
        setMainFragmentByPreset(CropDemoPreset.RECT);
    }
}
 
开发者ID:chuch0805,项目名称:Android-Demo_ImageCroper,代码行数:19,代码来源:MainActivity.java

示例10: initViews

import android.support.v7.app.ActionBarDrawerToggle; //导入依赖的package包/类
private void initViews() {

        toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
                this,
                drawer,
                toolbar,
                R.string.navigation_drawer_open,
                R.string.navigation_drawer_close);
        drawer.setDrawerListener(toggle);
        toggle.syncState();

        navigationView = (NavigationView) findViewById(R.id.nav_view);
        navigationView.setNavigationItemSelectedListener(this);

    }
 
开发者ID:makezhao,项目名称:LianXiZhihu,代码行数:20,代码来源:MainActivity.java

示例11: onCreate

import android.support.v7.app.ActionBarDrawerToggle; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    loadPortfolio();
    loadEDB();

    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    Fragment contentFragment = new SplashScreenFragment();
    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    ft.replace(R.id.content_frame, contentFragment);
    ft.commit();
}
 
开发者ID:CIS-Extra,项目名称:mazes_and_minotaurs,代码行数:25,代码来源:MainMazes.java

示例12: onCreate

import android.support.v7.app.ActionBarDrawerToggle; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
}
 
开发者ID:smallsilver,项目名称:VerticalWebView,代码行数:26,代码来源:MainActivity.java

示例13: onCreate

import android.support.v7.app.ActionBarDrawerToggle; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);



    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    if (savedInstanceState == null) {
        // on first time to display view for first navigation item based on the number
        navigationView.getMenu().getItem(0).setChecked(true);
        onNavigationItemSelected(navigationView.getMenu().getItem(0));
    }

}
 
开发者ID:anonymous-ME,项目名称:Automata,代码行数:26,代码来源:Main.java

示例14: onCreate

import android.support.v7.app.ActionBarDrawerToggle; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_main);
    setSupportActionBar(toolbar);

    ButterKnife.bind(this);

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    setupData();
}
 
开发者ID:xhd-Git,项目名称:3DPrint-Controller,代码行数:21,代码来源:MainActivity.java

示例15: onCreate

import android.support.v7.app.ActionBarDrawerToggle; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open,
            R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    Fragment nowPlayingFragment = MovieListFragment.newInstance(new NowPlayingMoviePresenter(),
            R.string.nav_now_playing);
    setMovieFragment(nowPlayingFragment, MOVIES_FRAGMENT_TAG);
}
 
开发者ID:ramadani,项目名称:Pilem,代码行数:23,代码来源:MainActivity.java


注:本文中的android.support.v7.app.ActionBarDrawerToggle类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。