本文整理汇总了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;
}
示例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
}
}
}
示例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);
}
}
}
示例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;
}
示例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;
}
示例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();
}
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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
}
}
示例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();
}
}
示例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();
}
}