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

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

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

DrawerLayout.addDrawerListener介绍

暂无

代码示例

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

@Override
public void initView() {
  ActionBarDrawerToggle mDrawerToggle = new ActionBarDrawerToggle(this, mViewBinding.dlMainDrawer, R.string.drawer_open, R.string.drawer_close);
  mDrawerToggle.syncState();
  mViewBinding.dlMainDrawer.addDrawerListener(mDrawerToggle);
  mViewBinding.nvMainNavigation.setNavigationItemSelectedListener(this);
}

代码示例来源:origin: arimorty/floatingsearchview

public void attachNavigationDrawerToMenuButton(@NonNull DrawerLayout drawerLayout) {
  drawerLayout.addDrawerListener(mDrawerListener);
  setOnLeftMenuClickListener(new NavDrawerLeftMenuClickListener(drawerLayout));
}

代码示例来源:origin: k9mail/k-9

private void initializeDrawer(Bundle savedInstanceState) {
  if (!isDrawerEnabled()) {
    return;
  }
  drawer = new K9Drawer(this, savedInstanceState);
  DrawerLayout drawerLayout = drawer.getLayout();
  drawerToggle = new ActionBarDrawerToggle(
      this, drawerLayout, null,
      R.string.navigation_drawer_open, R.string.navigation_drawer_close
  );
  drawerLayout.addDrawerListener(drawerToggle);
  drawerToggle.syncState();
}

代码示例来源:origin: Rukey7/MvpApp

/**
 * 初始化 DrawerLayout
 *
 * @param drawerLayout DrawerLayout
 * @param navView      NavigationView
 */
private void _initDrawerLayout(DrawerLayout drawerLayout, NavigationView navView) {
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
    WindowManager.LayoutParams localLayoutParams = getWindow().getAttributes();
    localLayoutParams.flags = (WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | localLayoutParams.flags);
    //将侧边栏顶部延伸至status bar
    drawerLayout.setFitsSystemWindows(true);
    //将主页面顶部延伸至status bar
    drawerLayout.setClipToPadding(false);
  }
  drawerLayout.addDrawerListener(new DrawerLayout.SimpleDrawerListener() {
    @Override
    public void onDrawerClosed(View drawerView) {
      mHandler.sendEmptyMessage(mItemId);
    }
  });
  navView.setNavigationItemSelectedListener(this);
}

代码示例来源:origin: Clans/FloatingActionButton

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main_activity);
  Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
  setSupportActionBar(toolbar);
  mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
  ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
      this, mDrawerLayout, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
  mDrawerLayout.addDrawerListener(toggle);
  toggle.syncState();
  NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
  navigationView.setNavigationItemSelectedListener(navigationItemSelectedListener);
  if (savedInstanceState == null) {
    getSupportFragmentManager().beginTransaction()
        .add(R.id.fragment, new HomeFragment()).commit();
  }
  navigationView.setCheckedItem(R.id.home);
}

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

@Implementation
public void addDrawerListener(DrawerLayout.DrawerListener drawerListener) {
  this.drawerListeners.add(drawerListener);
  directlyOn(realDrawerLayout, DrawerLayout.class).addDrawerListener(drawerListener);
}

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

drawerLayout.addDrawerListener(drawerToggle);

代码示例来源:origin: MindorksOpenSource/android-mvp-architecture

@Override
protected void setUp() {
  setSupportActionBar(mToolbar);
  mDrawerToggle = new ActionBarDrawerToggle(
      this,
      mDrawer,
      mToolbar,
      R.string.open_drawer,
      R.string.close_drawer) {
    @Override
    public void onDrawerOpened(View drawerView) {
      super.onDrawerOpened(drawerView);
      hideKeyboard();
    }
    @Override
    public void onDrawerClosed(View drawerView) {
      super.onDrawerClosed(drawerView);
    }
  };
  mDrawer.addDrawerListener(mDrawerToggle);
  mDrawerToggle.syncState();
  setupNavMenu();
  mPresenter.onNavMenuCreated();
  setupCardContainerView();
  mPresenter.onViewInitialized();
}

代码示例来源:origin: JohnPersano/SuperToasts

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
  setSupportActionBar(toolbar);
  final DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
  final ActionBarDrawerToggle actionBarDrawerToggle = new ActionBarDrawerToggle(
      this, drawerLayout, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close) {
    @Override
    public void onDrawerSlide(View drawerView, float slideOffset) {
      // Stop animating the navigation icon
      super.onDrawerSlide(drawerView, 0);
    }
  };
  drawerLayout.addDrawerListener(actionBarDrawerToggle);
  actionBarDrawerToggle.syncState();
  final NavigationView navigationView = (NavigationView) findViewById(R.id.navigation_view);
  navigationView.setNavigationItemSelectedListener(this);
  navigationView.setCheckedItem(R.id.navigation_drawer_supertoast);
  // setCheckedItem() does not actually call the associated listener
  if (savedInstanceState == null) this.onNavigationItemSelected(navigationView.getMenu().getItem(0));
}

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

drawer.addDrawerListener(toggle);
drawer.addDrawerListener(new DrawerLayout.SimpleDrawerListener() {
  private int lastService;

代码示例来源:origin: BaronZ88/MinimalistWeather

this, drawerLayout, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
assert drawerLayout != null;
drawerLayout.addDrawerListener(toggle);
toggle.syncState();

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

mDrawerLayout.addDrawerListener(mDrawerToggle);
PreferenceManager.getDefaultSharedPreferences(this)
    .registerOnSharedPreferenceChangeListener(mLoginListener);

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

ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
    this, drawer_layout, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer_layout.addDrawerListener(toggle);
toggle.syncState();

代码示例来源:origin: palaima/DebugDrawer

@Override
public void onViewAttachedToWindow(View view) {
  if (drawerLayout != null) {
    drawerLayout.addDrawerListener(listener);
  }
}

代码示例来源:origin: janishar/PlaceHolderView

private void setupDrawer(){
  mDrawerView
      .addView(new DrawerHeader())
      .addView(new DrawerMenuItem(this.getApplicationContext()))
      .addView(new DrawerMenuItem(this.getApplicationContext()))
      .addView(new DrawerMenuItem(this.getApplicationContext()))
      .addView(new DrawerMenuItem(this.getApplicationContext()))
      .addView(new DrawerMenuItem(this.getApplicationContext()))
      .addView(new DrawerMenuItem(this.getApplicationContext()))
      .addView(new DrawerMenuItem(this.getApplicationContext()))
      .addView(new DrawerMenuItem(this.getApplicationContext()));
  ActionBarDrawerToggle  drawerToggle = new ActionBarDrawerToggle(this, mDrawer, mToolbar, R.string.open_drawer, R.string.close_drawer){
    @Override
    public void onDrawerOpened(View drawerView) {
      super.onDrawerOpened(drawerView);
    }
    @Override
    public void onDrawerClosed(View drawerView) {
      super.onDrawerClosed(drawerView);
    }
  };
  mDrawer.addDrawerListener(drawerToggle);
  drawerToggle.syncState();
}

代码示例来源:origin: glomadrian/RoadRunner

private void configureToolbar() {
 setSupportActionBar(toolbar);
 getSupportActionBar().setDisplayHomeAsUpEnabled(true);
 getSupportActionBar().setHomeButtonEnabled(true);
 actionBarDrawerToggle =
   new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.app_name,
     R.string.app_name);
 drawerLayout.addDrawerListener(actionBarDrawerToggle);
 actionBarDrawerToggle.setDrawerIndicatorEnabled(true);
 actionBarDrawerToggle.syncState();
}

代码示例来源:origin: eneim/toro

drawer.addDrawerListener(drawerToggle);
drawer.addDrawerListener(containerToggle);

代码示例来源:origin: chenyangcun/MaterialDesignExample

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  mToolbar = (Toolbar) findViewById(R.id.toolbar);
  setSupportActionBar(mToolbar);
  mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
  mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, mToolbar, R.string.drawer_open,
      R.string.drawer_close);
  mDrawerToggle.syncState();
  mDrawerLayout.addDrawerListener(mDrawerToggle);
  mNavigationView = (NavigationView) findViewById(R.id.navigation_view);
  setupDrawerContent(mNavigationView);
  //profile Image
  setUpProfileImage();
  switchToBook();
}

代码示例来源:origin: thyrlian/AwesomeValidation

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_demo);
  mViewSuccess = (LinearLayout) findViewById(R.id.container_success);
  mScrollView = (ScrollView) findViewById(R.id.scroll_view);
  mViewContainerEditText = findViewById(R.id.container_edit_text);
  mViewContainerTextInputLayout = findViewById(R.id.container_text_input_layout);
  mStyles = getResources().getStringArray(R.array.styles);
  mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
  Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
  if (toolbar != null) {
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
      actionBar.setDisplayHomeAsUpEnabled(true);
    }
  }
  setupSpinner();
  // AwesomeValidation.disableAutoFocusOnFirstFailure();
  mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, toolbar, R.string.app_name, R.string.app_name);
  mDrawerLayout.addDrawerListener(mDrawerToggle);
  mDrawerList = (ListView) findViewById(R.id.left_drawer);
  mDrawerList.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_list_item, mStyles));
  mDrawerList.setOnItemClickListener(mDrawerItemClickListener);
  mDrawerItemClickListener.selectItem(mPosition);
}

代码示例来源:origin: TakWolf/CNode-Material-Design

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
  enableThemeDark = ThemeUtils.configThemeBeforeOnCreate(this, R.style.AppThemeLight, R.style.AppThemeDark);
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  ButterKnife.bind(this);
  drawerLayout.setDrawerShadow(R.drawable.navigation_drawer_shadow, GravityCompat.START);
  drawerLayout.addDrawerListener(drawerListener);
  toolbar.setNavigationOnClickListener(new NavigationOpenClickListener(drawerLayout));
  toolbar.setOnClickListener(new DoubleClickBackToContentTopListener(this));
  navItemDev.setVisibility(BuildConfig.DEBUG ? View.VISIBLE : View.GONE);
  recyclerView.setLayoutManager(new LinearLayoutManager(this));
  loadMoreFooter = new LoadMoreFooter(this, recyclerView, this);
  adapter = new TopicListAdapter(this);
  recyclerView.setAdapter(adapter);
  recyclerView.addOnScrollListener(new FloatingActionButtonBehaviorListener.ForRecyclerView(fabCreateTopic));
  mainPresenter = new MainPresenter(this, this);
  updateUserInfoViews();
  imgThemeDark.setImageResource(enableThemeDark ? R.drawable.ic_wb_sunny_white_24dp : R.drawable.ic_brightness_3_white_24dp);
  navTopBackground.setVisibility(enableThemeDark ? View.INVISIBLE : View.VISIBLE);
  refreshLayout.setColorSchemeResources(R.color.color_accent);
  refreshLayout.setOnRefreshListener(this);
  refreshLayout.setRefreshing(true);
  onRefresh();
}

相关文章