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


Java DrawerLayout.closeDrawer方法代码示例

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


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

示例1: onNavigationItemSelected

import android.support.v4.widget.DrawerLayout; //导入方法依赖的package包/类
@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();

    if (id == R.id.nav_warning) {
        // Handle the camera action
    } else if (id == R.id.nav_logs) {

    } else if (id == R.id.nav_aboutthis) {

    } else if (id == R.id.nav_aboutthis) {

    } else if (id == R.id.nav_aboutus) {

    } else if (id == R.id.nav_github) {

    }

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
}
 
开发者ID:borjalor,项目名称:DroidSentinel,代码行数:25,代码来源:MainActivity.java

示例2: onBackPressed

import android.support.v4.widget.DrawerLayout; //导入方法依赖的package包/类
@Override
public void onBackPressed() {
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout_main);
    if (drawer.isDrawerOpen(GravityCompat.START)) {
        drawer.closeDrawer(GravityCompat.START);
    } else {
        if (OnceBackClicked)
            super.onBackPressed();
        else {
            Toast.makeText(getApplicationContext(), R.string.ClickToExit, Toast.LENGTH_SHORT).show();
            OnceBackClicked = true;
            Runnable runnable = new Runnable() {
                @Override
                public void run() {
                    OnceBackClicked = false; //reset back pressed event
                }
            };
            new android.os.Handler().postDelayed(runnable, 2000); //reset the click stat after 2 seconds
        }
    }
}
 
开发者ID:coder3101,项目名称:Matrix-Calculator-for-Android,代码行数:22,代码来源:MainActivity.java

示例3: onBackPressed

import android.support.v4.widget.DrawerLayout; //导入方法依赖的package包/类
@Override
   public void onBackPressed()
{
       DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    if (drawer.isDrawerOpen(GravityCompat.START) || drawer.isDrawerOpen(GravityCompat.END))
	{
		if (drawer.isDrawerOpen(GravityCompat.START)){
        	   drawer.closeDrawer(GravityCompat.START);
		  } 
		if (drawer.isDrawerOpen(GravityCompat.END)){
			drawer.closeDrawer(GravityCompat.END);
		}
       }
	else
	{
		if (mWebView.canGoBack())
		{
			mWebView.goBack();
		}
		else
		{
			showSnackBar("退出?", "确定", 1);
		}
       }
   }
 
开发者ID:gtf35,项目名称:easyShopping,代码行数:26,代码来源:Main.java

示例4: onNavigationItemSelected

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

    if (id == R.id.nav_published) {
        loadFragment(FN_LIVE);
    } else if (id == R.id.nav_draft) {
        loadFragment(FN_DRAFT);
    } else if (id == R.id.nav_activities) {
        loadFragment(FN_ACTIVITIES);
    } else if (id == R.id.nav_app_settings) {
        loadFragment(FN_APP_SETTINGS);
    } else if (id == R.id.nav_about) {
        loadFragment(FN_ABOUT);
    }

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
}
 
开发者ID:thenewpotato,项目名称:Blogg,代码行数:22,代码来源:MainActivity.java

示例5: onNavigationItemSelected

import android.support.v4.widget.DrawerLayout; //导入方法依赖的package包/类
@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();

    if (id == R.id.nav_camera) {
        // Handle the camera action
    } else if (id == R.id.nav_gallery) {

    } else if (id == R.id.nav_slideshow) {

    } else if (id == R.id.nav_manage) {

    } else if (id == R.id.nav_share) {

    } else if (id == R.id.nav_send) {

    }

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);

    getGaTracker().sendNavigationDrawerItemClick(item.getTitle().toString(), null, true);
    return true;
}
 
开发者ID:smashingboxes,项目名称:android-analytics,代码行数:27,代码来源:MainActivity.java

示例6: onBackPressed

import android.support.v4.widget.DrawerLayout; //导入方法依赖的package包/类
@Override
public void onBackPressed() {
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    if (drawer.isDrawerOpen(GravityCompat.START)) {
        drawer.closeDrawer(GravityCompat.START);
    } else {
        super.onBackPressed();
    }
}
 
开发者ID:ayounes3333,项目名称:GSB-2017-Android,代码行数:10,代码来源:MainActivity.java

示例7: onNavigationItemSelected

import android.support.v4.widget.DrawerLayout; //导入方法依赖的package包/类
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
    int id = item.getItemId();
    switch (id) {
        case R.id.nav_login:
            Toast.makeText(this, getString(R.string.coming_soon), Toast.LENGTH_SHORT).show();
            //startActivityForResult(new Intent(this, LoginActivity.class), 0);
            break;
        case R.id.nav_collections:
            startActivity(new Intent(this, CollectionsActivity.class));
            break;
        case R.id.nav_icons:
            startActivity(new Intent(this, IconsActivity.class));
            break;
        case R.id.nav_legal:
            Intent intent = new Intent(Intent.ACTION_VIEW,
                    Uri.parse(BuildConfig.NOUN_PROJECT_BASE_URL + "/legal"));
            startActivity(intent);
            break;
        case R.id.nav_about:
            AboutDialog.newInstance().show(getSupportFragmentManager());
            break;
    }
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer);
    drawer.closeDrawer(GravityCompat.START);
    return true;
}
 
开发者ID:graviton57,项目名称:TheNounProject,代码行数:28,代码来源:MainActivity.java

示例8: onNavigationItemSelected

import android.support.v4.widget.DrawerLayout; //导入方法依赖的package包/类
@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();

    if (id == R.id.nav_camera) {
        // Home

    } else if (id == R.id.nav_gallery) {
        // Profile
        startActivity(new Intent(getBaseContext(), ProfileActivity.class));
    } else if (id == R.id.nav_slideshow) {
        // My Items
        startActivity(new Intent(getBaseContext(), MyItemsActivity.class));
    } else if (id == R.id.nav_manage) {
        // Logout
        mAuth.signOut();
        startActivity(new Intent(getBaseContext(), LoginActivity.class));
    }
    else if(id == R.id.nav_search) {
        startActivity(new Intent(getBaseContext(), SearchActivity.class));
    }

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
}
 
开发者ID:ppdesai434,项目名称:MavsSnapUp,代码行数:29,代码来源:HomeActivity.java

示例9: onBackPressed

import android.support.v4.widget.DrawerLayout; //导入方法依赖的package包/类
@Override
public void onBackPressed() {
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    if (drawer.isDrawerOpen(GravityCompat.START)) {
        drawer.closeDrawer(GravityCompat.START);
    } else {
        Intent i = new Intent();
        i.setAction(Intent.ACTION_MAIN);
        i.addCategory(Intent.CATEGORY_HOME);
        this.startActivity(i);
    }
}
 
开发者ID:Wisebite,项目名称:wisebite_android,代码行数:13,代码来源:MainActivity.java

示例10: 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

示例11: onBackPressed

import android.support.v4.widget.DrawerLayout; //导入方法依赖的package包/类
@Override
public void onBackPressed() {
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    if (drawer.isDrawerOpen(GravityCompat.START)) {
        drawer.closeDrawer(GravityCompat.START);
    } else {
        super.onBackPressed();
        System.exit(0); // EXIT THE APPLICATION NORMALLY
    }
}
 
开发者ID:FYP17-4G,项目名称:Aardvark,代码行数:11,代码来源:GUI_MainActivity.java

示例12: onBackPressed

import android.support.v4.widget.DrawerLayout; //导入方法依赖的package包/类
@Override
public void onBackPressed() {
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.match_drawer_layout);
    if (drawer.isDrawerOpen(GravityCompat.START)) {
        drawer.closeDrawer(GravityCompat.START);
    } else {
        super.onBackPressed();
    }
}
 
开发者ID:chrisqz95,项目名称:couch-potatoes,代码行数:10,代码来源:MatchingActivity.java

示例13: onBackPressed

import android.support.v4.widget.DrawerLayout; //导入方法依赖的package包/类
@Override
public void onBackPressed() {
    DrawerLayout drawer = findViewById(R.id.chatroom_drawer_layout);
    if (drawer.isDrawerOpen(GravityCompat.START)) {
        drawer.closeDrawer(GravityCompat.START);
    } else {
        super.onBackPressed();
    }
}
 
开发者ID:chrisqz95,项目名称:couch-potatoes,代码行数:10,代码来源:ChatRoomActivity.java


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