使用isInEditMode解决可视化编辑器无法识别自定义控件的问题
来源:互联网 发布:fifaol317球员数据库 编辑:程序博客网 时间:2024/06/05 19:50
isInEditMode:
Indicates whether this View is currently in edit mode. A View is usually in edit mode when displayed within a developer tool. For instance, if this View is being drawn by a visual user interface builder, this method should return true. Subclasses should check the return value of this method to provide different behaviors if their normal behavior might interfere with the host environment. For instance: the class spawns a thread in its constructor, the drawing code relies on device-specific features, etc. This method is usually checked in the drawing code of custom widgets.
如果在自定义控件的构造函数或者其他绘制相关地方使用系统依赖的代码,会导致可视化编辑器无法报错并提示:Use View.isInEditMode() in your custom views to skip code when shown in Eclipse
比如:
public class LockRelativeLayout extends RelativeLayout {
private Handler mainHandler = null; //与主Activity通信的Handler对象
public LockRelativeLayout(Context context, AttributeSet attrs) {
super(context, attrs, 0);
mContext = context;
if (isInEditMode()) { return; }
mainHandler = ((SPActivity)mContext).getMHandler();
}
}
如果不加上if (isInEditMode()) { return; },标红处代码会导致可视化编辑报错
- isInEditMode解决可视化编辑器无法识别自定义控件的问题
- 使用isInEditMode解决可视化编辑器无法识别自定义控件的问题
- 使用isInEditMode解决可视化编辑器无法识别自定义控件的问题
- 使用isInEditMode解决可视化编辑器无法识别自定义控件的问题
- (4.1.36.9)使用isInEditMode解决可视化编辑器无法识别自定义控件的问题
- 使用isInEditMode解决可视化编辑器无法识别自定义控件的问题
- 解决可视化编辑器无法识别自定义控件的问题
- 功能测试自动化视频---解决自定义控件的无法识别问题
- 自定义控件无法在Eclipse的Android界面编辑器的可视化模式下显示
- WordPress可视化编辑器问题的解决
- 解决WPF引用无法识别的问题
- 解决 avformat_alloc_context无法识别的问题
- 解决TSLIB无法识别触摸屏的问题
- QTP学习笔记(一):安装篇,解决QTP无法识别控件对象的问题
- 解决VS2010使用mscomm控件无法接收数据的问题
- 自定义的view无法在layou视图中查看 ,How to use isInEditMode()
- Android使用自定义控件遇到的问题及解决
- 自定义控件id无法被识别的解决方法
- 程序员技术练级攻略
- android或Java中 系统日期时间的获取总结大全
- extjs4.1 动态加载 checkboxgroup 后checked 为true老是失效的问题+combobo自动选择特定记录
- UNIX域嵌套字 ——服务器的实现
- 使用FFMPEG SDK解码流数据
- 使用isInEditMode解决可视化编辑器无法识别自定义控件的问题
- 儒家修身 笔记
- 函数例子
- 如何设置jquery的ajax方法为同步
- 小东西——大智慧
- LayoutInflater和inflate()方法的用法
- git使用说明(Linux系统)
- C++构造函数初始化顺序
- oracle常用系统表