Android 在使用自定义控件的时候,会提示这样的错误信息:

not using the 2- or 3-argument View constructors; XML attributes will not work

往是由于你只定义了一个构造函数,解决方法就是至少要定义两个构造函数

处理如下:

public SlideButton(Context context) {super(context);initBitmap();}public SlideButton(Context context, AttributeSet attrs){super(context,attrs);initBitmap();}public SlideButton(Context context,AttributeSet attrs,int defStyle){super(context,attrs,defStyle);initBitmap();}

如果你只写了第一个构造函数,那么就会扡这个错误,至少要写上第二个或第三个构造函数才可以!!

更多相关文章

  1. android Dialog 各种Dialog 三个选项的、进度条的、单选的、多选
  2. 用户界面View之ProgressBar
  3. ANDROID GUI
  4. android 动态添加控件并实现每个子控件的点击事件
  5. android4.0 hid插入提示
  6. 【Android】Android(安卓)UI 开发_习题
  7. Android中onTouch方法的执行过程以及和onClick执行发生冲突的解
  8. Android(安卓)添加标签;角标;控件角落添加Tip
  9. 升级Android(安卓)Studio 3.6.1 后无法运行 Java 的main函数问题

随机推荐

  1. android 学习笔记(二)
  2. 主界面监听返回键,退出程序
  3. 隐藏android中EditText的下划线
  4. Flutter实现android应用内版本更新功能
  5. Android(安卓)字符串格式化 千位符
  6. Java中的instanceof关键字在Android中的
  7. android客户端发送XML数据至服务器
  8. android获取文件目录
  9. android 使用VideoView加载raw目录内视频
  10. 2011.09.01(4)——— android 应用程序跳转