ButterKnife.bind(this)发生NullPointerException
来源:互联网 发布:成交量macd指标源码 编辑:程序博客网 时间:2024/05/29 07:44
最近做项目,想用黄油刀,刚开始看了写官方的文档,好简单啊,直接把库compile进来,上去就是@BindView(R.id.tx) TextView tv,当我在setContentView里面去set这个TextView的值的时候报空指针异常了,我怎么想怎么不对,然后用@onClick去给TextView设置监听也不管用,感觉这个框架没什么用处啊,也是害苦了,还是去官网再好好看看,终于看到自己的坑了,单单去compile一个库是完全没有用的
官方导入图
需要添加buildscript{ }、apply plugin: ‘android-apt’还有 apt ‘com.jakewharton:butterknife-compiler:8.4.0’。单单compile一点用都没
我的图
ok,再不会报空指针异常了
用法
在初始化的时候 ButterKnife.bind(this);
成员变量 @BindView(R.id.main_home) ImageView imgHome;
添加单击事件 @OnClick(R.id.submit) void submit() { // TODO call server... }
添加多个单击事件 @OnClick({R.id.main_home, R.id.main_car, R.id.main_square, R.id.main_msg, R.id.main_my}) public void onClick(View v) { switch (v.getId()){ case R.id.main_home: //do something break; } }
好了,最近没做应用,博客一直都停着没写,接下来估计就是忙的时候了,遇到问题总结后再来博客分享,继续代码生活
0 0
- ButterKnife.bind(this)发生NullPointerException
- ButterKinfe.bind(this) @BindView时出现NullPointerException
- android butterknife NullPointerException 解决方法
- butterknife 混淆 NullpointerException
- ButterKnife 报NullPointerexception
- ButterKnife使用出现Nullpointerexception
- 使用Butterknife注解出现nullPointerException异常
- Eclipse中使用butterknife出现nullPointerException
- ButterKnife 8.0.1 @BindView 失败,nullpointerexception
- ButterKnife 8.0.1 @BindView 失败,nullpointerexception
- ButterKnife 8.4.0 @BindView 失败,nullpointerexception
- ButterKnife BindView 失败,报错NullPointerException
- ButterKnife 8.0.1 @BindView 失败,nullpointerexception
- 依赖butterknife:8.8.1 控件NullPointerException解决办法
- $(this).bind("change",itemno_change);
- react系列-bind this
- React的bind(this)
- ES6 中的 bind(this)
- scannner的小程序!!!
- 20160928 召回率统计所用的技术
- SUID,SGID原理
- 前端开发工具
- Android 仿iOS上拉下拉界面的效果实现
- ButterKnife.bind(this)发生NullPointerException
- 从0开始学习 GITHUB 系列之「初识 GITHUB」
- 聊聊Clip-Path
- ios 响应者链
- 如何进行水文分析图
- Going to buffer response body of large or unknown size. Using getResponseBodyAsStream instead is rec
- 视音频数据处理入门:RGB、YUV像素数据处理
- ORACLE数据库杀掉会话进程的三种方式及案例分析
- hxy系列4-最优化与梯度下降