From 60341f65b7a1fc958d6557f77dcefca03e8fb78f Mon Sep 17 00:00:00 2001 From: chaychan <844738237@qq.com> Date: Tue, 19 Dec 2017 11:21:36 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=9B=9E=E8=B0=83onItemSelec?= =?UTF-8?q?ted=E4=B8=A4=E6=AC=A1=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/chaychan/library/BottomBarLayout.java | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/library/src/main/java/com/chaychan/library/BottomBarLayout.java b/library/src/main/java/com/chaychan/library/BottomBarLayout.java index 6d89a06..6f07dd9 100644 --- a/library/src/main/java/com/chaychan/library/BottomBarLayout.java +++ b/library/src/main/java/com/chaychan/library/BottomBarLayout.java @@ -88,7 +88,6 @@ public class BottomBarLayout extends LinearLayout implements ViewPager.OnPageCha public void onPageSelected(int position) { resetState(); mItemViews.get(position).setStatus(true); - mViewPager.setCurrentItem(position, mSmoothScroll); if (onItemSelectedListener != null){ onItemSelectedListener.onItemSelected(getBottomItem(position),position); } @@ -111,17 +110,11 @@ public class BottomBarLayout extends LinearLayout implements ViewPager.OnPageCha @Override public void onClick(View v) { //回调点击的位置 - if (onItemSelectedListener != null) { + if (onItemSelectedListener != null && currentIndex == mCurrentItem) { onItemSelectedListener.onItemSelected(getBottomItem(currentIndex),currentIndex); } - //点击前先重置所有按钮的状态 - resetState(); - mItemViews.get(currentIndex).setStatus(true);//设置为选中状态 - //不能使用平滑滚动,否者颜色改变会乱 mViewPager.setCurrentItem(currentIndex, mSmoothScroll); - //点击是保存当前按钮索引 - mCurrentItem = currentIndex; } } -- GitLab