diff --git a/demo/src/main/java/com/chaychan/bottombarlayout/MainActivity.java b/demo/src/main/java/com/chaychan/bottombarlayout/MainActivity.java index f416d64..b5bbae6 100644 --- a/demo/src/main/java/com/chaychan/bottombarlayout/MainActivity.java +++ b/demo/src/main/java/com/chaychan/bottombarlayout/MainActivity.java @@ -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; @@ -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){ diff --git a/library/src/main/java/com/chaychan/library/BottomBarLayout.java b/library/src/main/java/com/chaychan/library/BottomBarLayout.java index 337d8a6..38c8492 100644 --- a/library/src/main/java/com/chaychan/library/BottomBarLayout.java +++ b/library/src/main/java/com/chaychan/library/BottomBarLayout.java @@ -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