android 微博tab,Android实现新浪微博客户端tab时遇到bug、

问题解决了、详细看回答一楼。。

但是有一个新的问题出现了,那就是在对RadioGroup设置onTouchListener监听器的时候,一直触发不了事件。。是因为RadioGroup设置不了触摸监听器吗还是怎么样?

·······························

我想要做一个类似新浪微博客户端的tab显示,当我选中某个按钮时,会有一个橙色的显示条表示选中,新浪微博客户端截图如下:

bVpMtc

我用了RadioGroup和自定义了一个继承LinearLayout的自定义控件(用来实现橙色条的显示),然后用TranslateAnimation来控制橙色下标的显示和移动动画、如下图所示。。

bVpMtN

下面是控制RadioGroup的监听器

/**

*ul_fm是我的自定义控件,rg_fm是radioGroup控件

*/

@Override

public void onCheckedChanged(RadioGroup group, int checkedId) {

int index = group.indexOfChild(rg_fm.findViewById(checkedId));

ul_fm.setCurrentItem(index);

}

自定义控件实现的代码:

/**

* 有动画的切换底部橙色导航栏

*

* @param item 需要显示橙色的下标

*/

public void setCurrentItem(int item) {

final View oldView = getChildAt(mCurrentItem);

final View newView = getChildAt(item);

TranslateAnimation translateAnimation = new TranslateAnimation(

Animation.REVERSE, 0,

Animation.REVERSE, item - mCurrentItem,

Animation.REVERSE, 0,

Animation.REVERSE, 0);

translateAnimation.setDuration(20);

translateAnimation.setAnimationListener(new Animation.AnimationListener() {

@Override

public void onAnimationStart(Animation animation) {

}

@Override

public void onAnimationEnd(Animation animation) {

oldView.setBackgroundResource(R.color.transparent);

newView.setBackgroundResource(R.color.orange);

oldView.clearAnimation();

}

@Override

public void onAnimationRepeat(Animation animation) {

}

});

oldView.setAnimation(translateAnimation);

mCurrentItem = item;

invalidate();

}

但是重点来了,实现了点击可以切换橙色下标的动画,但是有一个严重的bug,就是当我连续且快速的同时点击两个按钮时,会出现以下的情况,同时显示了两个橙色下标。。。

bVpMtT

求大神们帮忙看看

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值