當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。