android.support.v4.widget.DrawerLayout.closeDrawers()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(5.6k)|赞(0)|评价(0)|浏览(173)

本文整理了Java中android.support.v4.widget.DrawerLayout.closeDrawers()方法的一些代码示例,展示了DrawerLayout.closeDrawers()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DrawerLayout.closeDrawers()方法的具体详情如下:
包路径:android.support.v4.widget.DrawerLayout
类名称:DrawerLayout
方法名:closeDrawers

DrawerLayout.closeDrawers介绍

[英]Close all currently open drawer views by animating them out of view.
[中]通过在视图外设置动画来关闭所有当前打开的抽屉视图。

代码示例

代码示例来源:origin: Yalantis/Side-Menu.Android

@Override
  public void onClick(View v) {
    drawerLayout.closeDrawers();
  }
});

代码示例来源:origin: guolindev/booksource

@Override
  public boolean onNavigationItemSelected(MenuItem item) {
    mDrawerLayout.closeDrawers();
    return true;
  }
});

代码示例来源:origin: hidroh/materialistic

private void closeDrawers() {
    mDrawerLayout.closeDrawers();
  }
}

代码示例来源:origin: wangdan/AisenWeiBo

public void closeDrawer() {
  mDrawerLayout.closeDrawers();
}

代码示例来源:origin: chrisbanes/cheesesquare

@Override
  public boolean onNavigationItemSelected(MenuItem menuItem) {
    menuItem.setChecked(true);
    mDrawerLayout.closeDrawers();
    return true;
  }
});

代码示例来源:origin: joyoyao/superCleanMaster

public void closeDrawer() {
  mDrawerLayout.closeDrawers();
}

代码示例来源:origin: stackoverflow.com

public class MainActivity extends AppCompatActivity {

  NavigationView mNavigationView;
  DrawerLayout mDrawerLayout;

  // Other stuff

  private void init() {
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mNavigationView = (NavigationView) findViewById(R.id.navigation_view);
    mNavigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
      @Override
      public boolean onNavigationItemSelected(MenuItem menuItem) {
        mDrawerLayout.closeDrawers();
        menuItem.setChecked(true);
        switch (menuItem.getItemId()) {
          case R.id.nav_home:
            // TODO - Do something
            break;
          // TODO - Handle other items
        }
        return true;
      }
    });
  }
}

代码示例来源:origin: north2016/T-MVP

@Override
public void onBackPressed() {
  if (mViewBinding.dlMainDrawer.isDrawerOpen(Gravity.LEFT))
    mViewBinding.dlMainDrawer.closeDrawers();
  else super.onBackPressed();
}

代码示例来源:origin: Yalantis/Side-Menu.Android

@Override
public void onAnimationEnd(Animation animation) {
  view.clearAnimation();
  view.setVisibility(View.INVISIBLE);
  if (position == viewList.size() - 1) {
    animatorListener.enableHomeButton();
    drawerLayout.closeDrawers();
  }
}

代码示例来源:origin: stackoverflow.com

mDrawerLayout.closeDrawers();  // CLOSE DRAWER
return true;

代码示例来源:origin: Yalantis/Side-Menu.Android

@Override
public void enableHomeButton() {
  getSupportActionBar().setHomeButtonEnabled(true);
  drawerLayout.closeDrawers();
}

代码示例来源:origin: commonsguy/cw-omnibus

@Override
public void onItemClick(AdapterView<?> listView, View row,
            int position, long id) {
 if (position == 0) {
  showLorem();
 }
 else {
  showContent();
 }
 drawerLayout.closeDrawers();
}

代码示例来源:origin: commonsguy/cw-omnibus

@Override
public void onItemClick(AdapterView<?> listView, View row,
            int position, long id) {
 if (position == 0) {
  showLorem();
 }
 else {
  showContent();
 }
 drawerLayout.closeDrawers();
}

代码示例来源:origin: naman14/Timber

break;
case R.id.nav_about:
  mDrawerLayout.closeDrawers();
  Handler handler = new Handler();
  handler.postDelayed(new Runnable() {
mDrawerLayout.closeDrawers();
Handler handler = new Handler();
handler.postDelayed(new Runnable() {

代码示例来源:origin: aa112901/remusic

switch (position) {
  case 1:
    drawerLayout.closeDrawers();
    break;
  case 2:
    dialog.setClickListener(MainActivity.this);
    dialog.show(getSupportFragmentManager(), "theme");
    drawerLayout.closeDrawers();
    TimingFragment fragment3 = new TimingFragment();
    fragment3.show(getSupportFragmentManager(), "timing");
    drawerLayout.closeDrawers();
    BitSetFragment bfragment = new BitSetFragment();
    bfragment.show(getSupportFragmentManager(), "bitset");
    drawerLayout.closeDrawers();
    drawerLayout.closeDrawers();

代码示例来源:origin: guolindev/booksource

@Override
  public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    if (currentLevel == LEVEL_PROVINCE) {
      selectedProvince = provinceList.get(position);
      queryCities();
    } else if (currentLevel == LEVEL_CITY) {
      selectedCity = cityList.get(position);
      queryCounties();
    } else if (currentLevel == LEVEL_COUNTY) {
      String weatherId = countyList.get(position).getWeatherId();
      if (getActivity() instanceof MainActivity) {
        Intent intent = new Intent(getActivity(), WeatherActivity.class);
        intent.putExtra("weather_id", weatherId);
        startActivity(intent);
        getActivity().finish();
      } else if (getActivity() instanceof WeatherActivity) {
        WeatherActivity activity = (WeatherActivity) getActivity();
        activity.drawerLayout.closeDrawers();
        activity.swipeRefresh.setRefreshing(true);
        activity.requestWeather(weatherId);
      }
    }
  }
});

代码示例来源:origin: HotBitmapGG/bilibili-android-client

/**
 * 监听back键处理DrawerLayout和SearchView
 */
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
  if (keyCode == KeyEvent.KEYCODE_BACK) {
    if (mDrawerLayout.isDrawerOpen(mDrawerLayout.getChildAt(1))) {
      mDrawerLayout.closeDrawers();
    } else {
      if (mHomePageFragment != null) {
        if (mHomePageFragment.isOpenSearchView()) {
          mHomePageFragment.closeSearchView();
        } else {
          exitApp();
        }
      } else {
        exitApp();
      }
    }
  }
  return true;
}

代码示例来源:origin: iMeiji/Toutiao

drawer_layout.closeDrawers();
return false;
    .putExtra(Intent.EXTRA_TEXT, getString(R.string.share_app_text) + getString(R.string.source_code_url));
startActivity(Intent.createChooser(shareIntent, getString(R.string.share_to)));
drawer_layout.closeDrawers();
return false;

代码示例来源:origin: TeamNewPipe/NewPipe

private boolean drawerItemSelected(MenuItem item) {
  switch (item.getGroupId()) {
    case R.id.menu_services_group:
      changeService(item);
      break;
    case R.id.menu_tabs_group:
      try {
        tabSelected(item);
      } catch (Exception e) {
        ErrorActivity.reportUiError(this, e);
      }
      break;
    case R.id.menu_options_about_group:
      optionsAboutSelected(item);
      break;
    default:
      return false;
  }
  drawer.closeDrawers();
  return true;
}

代码示例来源:origin: wangdan/AisenWeiBo

mDrawerLayout.closeDrawers();
else
  mDrawerLayout.openDrawer(GravityCompat.START);

相关文章