频繁使用ViewFlipper这个控件,可以实现比较实用的页面切换,加上比Gallery方便扩展,所以会常常用到,但是在Android2.1及以上版本中出现系统bug,在进行横竖屏切换时会有如下系统报错:
详细解决方案
关于ViewFlipper在Android2.1及之上版本中的bug
热度:33 发布时间:2016-05-01 18:56:17.0
java.lang.IllegalArgumentException: Receiver not registered: [email protected]
在网上查到的原因是由于 onDetachedFromWindow() 莫名其妙地在 onAttachedToWindow() 之前被调用了。
解决方法是重写ViewFlipper的相关函数,try-catch一下完事,如下:
import android.content.Context;
import android.util.AttributeSet;
import android.widget.ViewFlipper;
public class MyViewFlipper extends ViewFlipper {
public MyViewFlipper(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
public MyViewFlipper(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}
@Override
protected void onDetachedFromWindow () {?
try {?
super.onDetachedFromWindow();?
} catch (IllegalArgumentException?e) {?
stopFlipping();?
}?
}
}
相关解决方案
- Android2.2 SDK 哪位高手有
- ActivityGroup + GridView + ViewFlipper 实现选项卡 引发的奇怪有关问题
- android2.3 使用libstagefrighthw.so显示yuv数据有关问题
- android2.3之后程序能自动开启GPS吗?(手机已root)解决方法
- android2.3 播放视频有关问题
- android中与Adapter相关的控件-ViewFlipper
- Android2.3与iPhone合体顺利
- Android基础入门教程——2.4.13 ViewFlipper(翻转视图)的根本使用
- Android2.4.7起动结构简述
- Android2.1有计算流量的方法么?解决思路
- Android2.2 不支持setRotation跟getRotation方法
- Android2.3上使用Tab切换界面,百度map黑屏个人解决办法
- Android2.2 - 4.X 障蔽 Home 键
- android2.3权限有关问题
- 攻 Android2.3.3中如何实现抽屉效果
- android2.3及4.0 AnsycTask差异与比较
- android2.3 旋转旋钮驱动
- android2.3.5系统源码?有人要吗解决办法
- android2.3上阿拉伯语展示顺序反了
- android2.3休眠唤醒后无法识别sd卡解决思路
- viewFlipper 需求,该如何处理
- Android2.2 JSON 有关问题
- android2.2 导入json常用包出现错误
- android2.1 Gallery3D的有关问题
- android2.3获取系统目前日期格式
- android2.3 动态壁纸无法使用的有关问题
- Android2.2安装时异常提示
- android2.3.4的touch事件传接过程 求教
- android2.2的LocalActivityManager的destroyActivity()有关问题
- Android2.2,2.3,4.0 中怎么使用GPU硬件加速原理 和游戏3D性能的提升