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