本文整理汇总了Java中android.support.v4.widget.DrawerLayout.closeDrawers方法的典型用法代码示例。如果您正苦于以下问题:Java DrawerLayout.closeDrawers方法的具体用法?Java DrawerLayout.closeDrawers怎么用?Java DrawerLayout.closeDrawers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.widget.DrawerLayout
的用法示例。
在下文中一共展示了DrawerLayout.closeDrawers方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onNavigationItemSelected
import android.support.v4.widget.DrawerLayout; //导入方法依赖的package包/类
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
int id = item.getItemId();
if (id == R.id.action_settings) {
showPreferences();
} else if (id == R.id.action_goto_start_url) {
mWebView.loadStartUrl();
} else if (id == R.id.action_reload) {
mWebView.reload();
} else if (id == R.id.action_start_app) {
Intent launchIntent = getLaunchIntent(this);
if (launchIntent != null) {
startActivity(launchIntent);
}
} else if (id == R.id.action_info) {
showInfoScreen();
} else if (id == R.id.action_help) {
showHelpScreen();
} else if (id == R.id.action_restart) {
destroy();
ProcessPhoenix.triggerRebirth(this);
} else if (id == R.id.action_exit) {
destroy();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
finishAndRemoveTask();
} else {
finish();
}
Runtime.getRuntime().exit(0);
}
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawers();
return true;
}
示例2: initMenu
import android.support.v4.widget.DrawerLayout; //导入方法依赖的package包/类
protected void initMenu() {
// Create the menu drawer
menuDrawerLayout = (RelativeLayout) findViewById(R.id.menu_drawer_layout);
menuDrawer = (DrawerLayout) findViewById(R.id.menu_drawer);
menuList = (ListView) findViewById(R.id.menu_drawer_list);
menuTitleArr = new String[]{"Library", "Playlists", "Albums", "Artists", "Genres", "Now Playing"};
menuIconArr = new int[]{R.drawable.ic_library, R.drawable.ic_menu_playlist, R.drawable.ic_album, R.drawable.ic_artist, R.drawable.ic_genre, R.drawable.ic_menu_play};
menuList.setAdapter(new MenuDrawerAdapter(this, menuTitleArr, menuIconArr));
menuDrawer.closeDrawers();
drawerOpen = false;
// Add hamburger icon to menu drawer
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, menuDrawer, mainBar, R.string.dialog_confirm, R.string.dialog_cancel);
menuDrawer.setDrawerListener(toggle);
toggle.setDrawerIndicatorEnabled(true);
toggle.syncState();
mainBar.setTitleTextColor(Color.WHITE);
mainBar.showOverflowMenu();
// Set listener
menuList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
selectMenuItem(i);
}
});
}
示例3: onBackPressed
import android.support.v4.widget.DrawerLayout; //导入方法依赖的package包/类
@Override
public void onBackPressed() {
if (this instanceof MainActivity) {
DrawerLayout drawerLayout = findViewById(R.id.drawer_layout);
if (drawerLayout.isDrawerOpen(GravityCompat.START)) {
drawerLayout.closeDrawers();
} else {
this.finish();
//Util.killAppProccess();
}
} else {
super.onBackPressed();
//this.overridePendingTransition(R.anim.trans_right_in, R.anim.trans_right_out);
}
}