当前位置: 首页>>代码示例>>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;未经允许,请勿转载。