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


Java DrawerLayout.setDrawerListener方法代码示例

本文整理汇总了Java中android.support.v4.widget.DrawerLayout.setDrawerListener方法的典型用法代码示例。如果您正苦于以下问题:Java DrawerLayout.setDrawerListener方法的具体用法?Java DrawerLayout.setDrawerListener怎么用?Java DrawerLayout.setDrawerListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v4.widget.DrawerLayout的用法示例。


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

示例1: onCreate

import android.support.v4.widget.DrawerLayout; //导入方法依赖的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

示例2: onCreate

import android.support.v4.widget.DrawerLayout; //导入方法依赖的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

示例3: onCreate

import android.support.v4.widget.DrawerLayout; //导入方法依赖的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

示例4: onCreate

import android.support.v4.widget.DrawerLayout; //导入方法依赖的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);
}
 
开发者ID:Kaufland,项目名称:andswipeframework,代码行数:17,代码来源:MainActivity.java

示例5: onCreate

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


    FragmentTransaction ft = getFragmentManager().beginTransaction();
    Fragment fragment = new FragmentFeed();
    ft.addToBackStack(null);
    ft.replace(R.id.content_main, fragment).commit();



    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:amigodeumamigomeu,项目名称:android-app-aam,代码行数:37,代码来源:MainActivity.java

示例6: onCreate

import android.support.v4.widget.DrawerLayout; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_navigation);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    Log.e("ddddd","dsfsfsf");
    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();

    ((BottomNavigationView)findViewById(R.id.navigation)).setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    mActivityDelegate = new ActivityGroupDelegate(this,savedInstanceState);
    mActivityGroupContainer = (ViewGroup) findViewById(R.id.content);
    switchToActivity("home","com.taobao.firstbundle.FirstBundleActivity");
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:22,代码来源:MainActivity.java

示例7: onCreate

import android.support.v4.widget.DrawerLayout; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    SampleSDK.runSdk();

    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, R.string.toast_replace_action, Snackbar.LENGTH_LONG)
                    .setAction(R.string.toast_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:smarkovik,项目名称:make-or-break,代码行数:29,代码来源:MainActivity.java

示例8: setDrawerListener

import android.support.v4.widget.DrawerLayout; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public static void setDrawerListener(DrawerLayout mDrawerLayout, ActionBarDrawerToggle mDrawerToggle)
{

    if (isMarshMallowOrLater())
    {
        mDrawerLayout.removeDrawerListener(mDrawerToggle);
        mDrawerLayout.addDrawerListener(mDrawerToggle);
    }
    else
    {
        mDrawerLayout.setDrawerListener(mDrawerToggle);
    }
}
 
开发者ID:mkulesh,项目名称:microMathematics,代码行数:15,代码来源:CompatUtils.java

示例9: onCreate

import android.support.v4.widget.DrawerLayout; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_home_options);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    fab = (FloatingActionButton) findViewById(R.id.fab);
    layoutFabSave = (LinearLayout) this.findViewById(R.id.layoutFabSave);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (fabExpanded == true){
                closeSubMenusFab();
            } else {
                openSubMenusFab();
            }
        }
    });

    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:DavidBorges,项目名称:Book-Tea_Project,代码行数:30,代码来源:HomeOptionsActivity.java

示例10: initMenu

import android.support.v4.widget.DrawerLayout; //导入方法依赖的package包/类
private void initMenu(ViewHolder holder) {
    Toolbar toolbar = holder.get(R.id.toolbar);
    toolbar.setLogo(R.mipmap.logo_actionbar);
    toolbar.setTitle("");
    DrawerLayout drawer = holder.get(R.id.drawer_layout);
    setSupportActionBar(toolbar);
    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);

    // 双击 666
    final GestureDetector detector = new GestureDetector(this, new GestureDetector.SimpleOnGestureListener() {
        @Override
        public boolean onDoubleTap(MotionEvent e) {
            quickToTop();   // 快速返回头部
            return super.onDoubleTap(e);
        }
    });

    toolbar.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            detector.onTouchEvent(event);
            return false;
        }
    });

    toolbar.setOnClickListener(this);

    holder.setOnClickListener(this, R.id.fab);

    loadMenuData();
}
 
开发者ID:GcsSloop,项目名称:diycode,代码行数:37,代码来源:MainActivity.java

示例11: onCreate

import android.support.v4.widget.DrawerLayout; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(mToolbar);

    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, mToolbar, 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);

    initView();
    mWindowManagerUtil = new TrackerWindowManager(this);

}
 
开发者ID:xmlxin,项目名称:ReplyMessage,代码行数:30,代码来源:MainActivity.java

示例12: onCreate

import android.support.v4.widget.DrawerLayout; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    TextView myTitle = (TextView) toolbar.getChildAt(0);
    Typeface tf = Typeface.createFromAsset(getAssets(),getResources().getString(R.string.font_name));
    myTitle.setTypeface(tf,Typeface.BOLD);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();
    AdView mAdView = (AdView)findViewById(R.id.adView);
    AdRequest adRequest = new AdRequest.Builder()
            .addTestDevice(getResources().getString(R.string.ad_device_test))
            .build();
    mAdView.loadAd(adRequest);
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    ViewPager viewPager = (ViewPager) findViewById(R.id.viewPager);
    viewPager.setAdapter(new PagerAdapter(getSupportFragmentManager()));
    TabLayout tabLayout = (TabLayout) findViewById(R.id.sliding_tabs);
    tabLayout.setupWithViewPager(viewPager);
}
 
开发者ID:MuditSrivastava,项目名称:Canvas-Vision,代码行数:28,代码来源:MainActivity.java

示例13: setupView

import android.support.v4.widget.DrawerLayout; //导入方法依赖的package包/类
@Override
protected void setupView() {
    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();

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

    View headerView = navigationView.getHeaderView(0);
    authenticatedLayout = headerView.findViewById(R.id.authenticated_layout);
    unauthenticatedLayout = headerView.findViewById(R.id.unauthenticated_layout);
    nameText = (TextView) headerView.findViewById(R.id.name_text);
    headerView.findViewById(R.id.show_login_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(MainActivity.this, LoginActivity.class);
            startActivity(intent);
        }
    });

    // Set up and select first item
    navigationView.setCheckedItem(R.id.nav_summary);
    presenter.navigateToSummaryPage();
}
 
开发者ID:mocircle,项目名称:devsuite-android,代码行数:31,代码来源:MainActivity.java

示例14: onCreate

import android.support.v4.widget.DrawerLayout; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_navigation);
    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:ynztlxdeai,项目名称:MVPtemplate,代码行数:30,代码来源:NavigationActivity.java

示例15: onCreate

import android.support.v4.widget.DrawerLayout; //导入方法依赖的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);
    findViewById(R.id.btnGenericXMLParser).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //doRemoteXMLParser();
            doLocalXMLParser();
        }
    });
}
 
开发者ID:AlawnXu,项目名称:XMLBaseParser,代码行数:33,代码来源:MainActivity.java


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