當前位置: 首頁>>代碼示例>>Java>>正文


Java DrawerLayout.openDrawer方法代碼示例

本文整理匯總了Java中android.support.v4.widget.DrawerLayout.openDrawer方法的典型用法代碼示例。如果您正苦於以下問題:Java DrawerLayout.openDrawer方法的具體用法?Java DrawerLayout.openDrawer怎麽用?Java DrawerLayout.openDrawer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.support.v4.widget.DrawerLayout的用法示例。


在下文中一共展示了DrawerLayout.openDrawer方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onCreate

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

    final 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();
        }
    });

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

    drawer.addDrawerListener(toggle);
    toggle.syncState();
    drawer.openDrawer(Gravity.START);
}
 
開發者ID:PacktPublishing,項目名稱:Hands-On-Android-UI-Development,代碼行數:26,代碼來源:NavigationMenuActivity.java

示例2: onOptionsItemSelected

import android.support.v4.widget.DrawerLayout; //導入方法依賴的package包/類
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.menu_start:
            containerStart(null);
            break;
        case R.id.menu_stop:
            containerStop(null);
            break;
        case R.id.menu_properties:
            containerProperties(null);
            break;
        case R.id.menu_install:
            containerDeploy();
            break;
        case R.id.menu_configure:
            containerConfigure();
            break;
        case R.id.menu_export:
            containerExportWithRequestPermissions();
            break;
        case R.id.menu_status:
            containerStatus();
            break;
        case R.id.menu_clear:
            clearLog();
            break;
        case android.R.id.home:
            DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
            if (drawer.isDrawerOpen(GravityCompat.START)) {
                drawer.closeDrawer(GravityCompat.START);
            } else {
                drawer.openDrawer(GravityCompat.START);
            }
            break;
        default:
            return super.onOptionsItemSelected(item);
    }
    return false;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:41,代碼來源:MainActivity.java

示例3: onBackPressed

import android.support.v4.widget.DrawerLayout; //導入方法依賴的package包/類
@Override
public void onBackPressed() { //the drawer is annoying to drag out, so let's open it on back press instead
    DrawerLayout drawer = findViewById(R.id.drawer_layout);
    if (drawer.isDrawerOpen(GravityCompat.START)) {
        drawer.closeDrawer(GravityCompat.START);
    } else if (!drawer.isDrawerOpen(GravityCompat.START)) {
        drawer.openDrawer(GravityCompat.START);
    } else {
        super.onBackPressed();
    }
}
 
開發者ID:zacharee,項目名稱:SystemUITuner2,代碼行數:12,代碼來源:MainActivity.java

示例4: onKeyUp

import android.support.v4.widget.DrawerLayout; //導入方法依賴的package包/類
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_MENU) {
        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        if (drawer.isDrawerOpen(GravityCompat.START)) {
            drawer.closeDrawer(GravityCompat.START);
        } else {
            drawer.openDrawer(GravityCompat.START);
        }
        return true;
    }
    return super.onKeyUp(keyCode, event);
}
 
開發者ID:kaliturin,項目名稱:BlackList,代碼行數:14,代碼來源:MainActivity.java

示例5: onOptionsItemSelected

import android.support.v4.widget.DrawerLayout; //導入方法依賴的package包/類
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {

        case android.R.id.home:
            if (this instanceof MainActivity) {
                DrawerLayout drawerLayout = findViewById(R.id.drawer_layout);
                drawerLayout.openDrawer(GravityCompat.START);
            } else {
                this.onBackPressed();
            }
            break;
    }
    return super.onOptionsItemSelected(item);
}
 
開發者ID:pedromassango,項目名稱:Programmers,代碼行數:16,代碼來源:BaseActivity.java

示例6: onBackPressed

import android.support.v4.widget.DrawerLayout; //導入方法依賴的package包/類
@Override
public void onBackPressed() {
    DrawerLayout drawer = findViewById(R.id.drawer_layout);
    if (drawer.isDrawerOpen(GravityCompat.START)) {
        drawer.closeDrawer(GravityCompat.START);
    } else {
        drawer.openDrawer(GravityCompat.START);
    }
}
 
開發者ID:coding-blocks,項目名稱:GSoC-Info-Android,代碼行數:10,代碼來源:HomeActivity.java

示例7: moveDrawer

import android.support.v4.widget.DrawerLayout; //導入方法依賴的package包/類
public void moveDrawer(DrawerLayout drawerLayout, int gravity){
    if (drawerLayout.isDrawerOpen(gravity)){
        drawerLayout.closeDrawer(gravity);
    } else {
        drawerLayout.openDrawer(gravity);
    }
}
 
開發者ID:Lazyeraser,項目名稱:DereHelper,代碼行數:8,代碼來源:Base.java

示例8: onContinuePressed

import android.support.v4.widget.DrawerLayout; //導入方法依賴的package包/類
public void onContinuePressed(View v) {
    drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.openDrawer(GravityCompat.START);
}
 
開發者ID:Durian-Inc,項目名稱:SwolyV2,代碼行數:5,代碼來源:MainActivity.java

示例9: openSideDrawer

import android.support.v4.widget.DrawerLayout; //導入方法依賴的package包/類
public void openSideDrawer(View v) {
    DrawerLayout dl = (DrawerLayout)findViewById(android.R.id.content).findViewById(R.id.drawer_layout);
    dl.openDrawer(dl.findViewById(R.id.left_drawer));
}
 
開發者ID:R-a-dio,項目名稱:R-a-dio-Amazing-Android-App,代碼行數:5,代碼來源:ActivityMain.java


注:本文中的android.support.v4.widget.DrawerLayout.openDrawer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。