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