Skip to content

Commit

Permalink
添加滑动监听,回调给onItemSelected
Browse files Browse the repository at this point in the history
  • Loading branch information
chaychan committed Dec 19, 2017
1 parent ac08f33 commit 26717fb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.animation.Animation;
import android.view.animation.RotateAnimation;
import android.widget.ImageView;
Expand Down Expand Up @@ -74,6 +75,7 @@ private void initListener() {
mBottomBarLayout.setOnItemSelectedListener(new BottomBarLayout.OnItemSelectedListener() {
@Override
public void onItemSelected(final BottomBarItem bottomBarItem, int position) {
Log.i("MainActivity","position: " + position);
if (position == 0){
//如果是第一个,即首页
if (mBottomBarLayout.getCurrentItem() == position){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,13 @@ public void onPageScrolled(int position, float positionOffset, int positionOffse

@Override
public void onPageSelected(int position) {
mCurrentItem = position;//记录当前位置
resetState();
mItemViews.get(position).setStatus(true);
mViewPager.setCurrentItem(position, mSmoothScroll);
if (onItemSelectedListener != null){
onItemSelectedListener.onItemSelected(getBottomItem(position),position);
}
mCurrentItem = position;//记录当前位置
}

@Override
Expand Down

0 comments on commit 26717fb

Please sign in to comment.