が
@Override
protected void onCreate(Bundle savedInstanceState) {
......
//Initialize
drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
//Setting the actionbarToggle to drawer layout
drawerLayout.setDrawerListener(actionBarDrawerToggle);
//calling sync state is necessay or else your hamburger icon wont show up
actionBarDrawerToggle.syncState();
}
DrawerListerner ...これを試してみてください閉じる/ OPE前のコード行を使用してください:
ActionBarDrawerToggle actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.app_name, R.string.app_name) {
@Override
public void onDrawerClosed(View drawerView) {
// Code here will be triggered once the drawer closes as we dont want anything to happen so we leave this blank
super.onDrawerClosed(drawerView);
InputMethodManager inputMethodManager = (InputMethodManager)
getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
}
@Override
public void onDrawerOpened(View drawerView) {
// Code here will be triggered once the drawer open as we dont want anything to happen so we leave this blank
super.onDrawerOpened(drawerView);
InputMethodManager inputMethodManager = (InputMethodManager)
getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
}
};
コーディングハッピー...
私はいつも困っています。 'Fragments'(' NavigationDrawer'または 'ViewPager'にあります)を使って' EditText'から 'WindowToken'を呼び出します。 'Activity.getCurrentFocus()'は私が欠けていたものでした。どうもありがとう。 – shkschneider