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


Java DrawerLayout.closeDrawers方法代码示例

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


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

示例1: onNavigationItemSelected

import android.support.v4.widget.DrawerLayout; //导入方法依赖的package包/类
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
    int id = item.getItemId();

    if (id == R.id.action_settings) {
        showPreferences();
    } else if (id == R.id.action_goto_start_url) {
        mWebView.loadStartUrl();
    } else if (id == R.id.action_reload) {
        mWebView.reload();
    } else if (id == R.id.action_start_app) {
        Intent launchIntent = getLaunchIntent(this);

        if (launchIntent != null) {
            startActivity(launchIntent);
        }
    } else if (id == R.id.action_info) {
        showInfoScreen();
    } else if (id == R.id.action_help) {
        showHelpScreen();
    } else if (id == R.id.action_restart) {
        destroy();
        ProcessPhoenix.triggerRebirth(this);
    } else if (id == R.id.action_exit) {
        destroy();
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            finishAndRemoveTask();
        } else {
            finish();
        }
        Runtime.getRuntime().exit(0);
    }

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawers();
    return true;
}
 
开发者ID:vbier,项目名称:habpanelviewer,代码行数:38,代码来源:MainActivity.java

示例2: initMenu

import android.support.v4.widget.DrawerLayout; //导入方法依赖的package包/类
protected void initMenu() {

        // Create the menu drawer
        menuDrawerLayout = (RelativeLayout) findViewById(R.id.menu_drawer_layout);
        menuDrawer = (DrawerLayout) findViewById(R.id.menu_drawer);
        menuList = (ListView) findViewById(R.id.menu_drawer_list);
        menuTitleArr = new String[]{"Library", "Playlists", "Albums", "Artists", "Genres", "Now Playing"};
        menuIconArr = new int[]{R.drawable.ic_library, R.drawable.ic_menu_playlist, R.drawable.ic_album, R.drawable.ic_artist, R.drawable.ic_genre, R.drawable.ic_menu_play};
        menuList.setAdapter(new MenuDrawerAdapter(this, menuTitleArr, menuIconArr));
        menuDrawer.closeDrawers();
        drawerOpen = false;

        // Add hamburger icon to menu drawer
        ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, menuDrawer, mainBar, R.string.dialog_confirm, R.string.dialog_cancel);
        menuDrawer.setDrawerListener(toggle);
        toggle.setDrawerIndicatorEnabled(true);
        toggle.syncState();
        mainBar.setTitleTextColor(Color.WHITE);
        mainBar.showOverflowMenu();

        // Set listener
        menuList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                selectMenuItem(i);
            }
        });
    }
 
开发者ID:Davarco,项目名称:Divertio,代码行数:29,代码来源:BaseListActivity.java

示例3: onBackPressed

import android.support.v4.widget.DrawerLayout; //导入方法依赖的package包/类
@Override
public void onBackPressed() {
    if (this instanceof MainActivity) {
        DrawerLayout drawerLayout = findViewById(R.id.drawer_layout);
        if (drawerLayout.isDrawerOpen(GravityCompat.START)) {
            drawerLayout.closeDrawers();
        } else {
            this.finish();
            //Util.killAppProccess();
        }
    } else {
        super.onBackPressed();
        //this.overridePendingTransition(R.anim.trans_right_in, R.anim.trans_right_out);
    }
}
 
开发者ID:pedromassango,项目名称:Programmers,代码行数:16,代码来源:BaseActivity.java


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