From 0bcad7141692abcbb59e64d65de3f2b9ca22a206 Mon Sep 17 00:00:00 2001 From: sakura <975976959@qq.com> Date: Tue, 27 Mar 2018 11:07:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=87=8D=E5=A4=8D=E7=82=B9?= =?UTF-8?q?=E5=87=BB=E8=BF=87=E6=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/modules.xml | 3 +++ .../sakura/bottomtabbar/BottomTabBar.java | 20 ++++++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/.idea/modules.xml b/.idea/modules.xml index 24e8692..cb66f15 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -3,8 +3,11 @@ + + + \ No newline at end of file diff --git a/bottomtabbar/src/main/java/sakura/bottomtabbar/BottomTabBar.java b/bottomtabbar/src/main/java/sakura/bottomtabbar/BottomTabBar.java index b8c3048..d547fb6 100644 --- a/bottomtabbar/src/main/java/sakura/bottomtabbar/BottomTabBar.java +++ b/bottomtabbar/src/main/java/sakura/bottomtabbar/BottomTabBar.java @@ -13,6 +13,7 @@ import android.support.v4.content.ContextCompat; import android.support.v4.view.ViewPager; import android.util.AttributeSet; +import android.util.Log; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; @@ -20,6 +21,7 @@ import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; + import java.util.ArrayList; import java.util.List; @@ -27,7 +29,7 @@ * Created by 赵磊 on 2017/8/11. */ -public class BottomTabBar extends LinearLayout implements ViewPager.OnPageChangeListener, View.OnClickListener { +public class BottomTabBar extends LinearLayout implements ViewPager.OnPageChangeListener, View.OnClickListener { private Context context; private LinearLayout mLayout; @@ -68,7 +70,7 @@ public class BottomTabBar extends LinearLayout implements ViewPager.OnPageChang private LinearLayout.LayoutParams tab_item_imgparams; private LayoutParams tab_item_tvparams; private int mReplaceLayout = 0; - private OnTabChangeListener listener=null; + private OnTabChangeListener listener = null; //mViewpager界面滑动 @Override @@ -108,9 +110,17 @@ public void onPageScrollStateChanged(int state) { } + View last = null; + //Tab点击事件处理 @Override public void onClick(View v) { + if (last == v) { + Log.e("BottomTabBar", "重复点击"); + return; + } else { + last = v; + } for (int i = 0; i < tabIdList.size(); i++) { if (tabIdList.get(i).equals(v.getTag())) { if (mViewpager != null) { @@ -126,7 +136,7 @@ public void onClick(View v) { changeTab(i); } //绑定点击监听回调 - if (listener!=null){ + if (listener != null) { listener.onTabChange(i, v); } } @@ -338,6 +348,7 @@ public BottomTabBar addTabItem(final String name, Drawable drawable) { tab_item_tv.setTextSize(fontSize); tab_item_tv.setText(name); if (tabIdList.size() == 1) { + last = TabItem; tab_item_tv.setTextColor(selectColor); } else { tab_item_tv.setTextColor(unSelectColor); @@ -379,6 +390,7 @@ public BottomTabBar addTabItem(final String name, Drawable selectdrawable, Drawa tab_item_tv.setTextSize(fontSize); tab_item_tv.setText(name); if (tabIdList.size() == 1) { + last = TabItem; tab_item_tv.setTextColor(selectColor); tab_item_img.setBackground(selectdrawable); } else { @@ -430,6 +442,7 @@ public BottomTabBar addTabItem(final String name, Drawable drawable, Class fragm tab_item_tv.setTextSize(fontSize); tab_item_tv.setText(name); if (tabIdList.size() == 1) { + last = TabItem; tab_item_tv.setTextColor(selectColor); } else { tab_item_tv.setTextColor(unSelectColor); @@ -480,6 +493,7 @@ public BottomTabBar addTabItem(final String name, Drawable selectdrawable, Drawa tab_item_tv.setTextSize(fontSize); tab_item_tv.setText(name); if (tabIdList.size() == 1) { + last = TabItem; tab_item_tv.setTextColor(selectColor); tab_item_img.setBackground(selectdrawable); } else {