使用ButterKnife无法inject view的解决办法
使用ButterKnife做android开发时,发现无法inject,如下,tvInfo总是null。
@InjectView(R.id.textView1Info) TextView tvInfo; @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main); ButterKnife.inject(this);
tvInfo.setText("test");// tvInfo is null.
}
后来在官网上找到解决办法,如下:
http://jakewharton.github.io/butterknife/ide-eclipse.html
Eclipse Configuration
Right click on your project in the Package Explorer. Head to Java Compiler → Annotation Processing and check "Enable project specific settings".
Ensure the other annotation processing settings are the same as shown below:

Expand the Annotation Processing section and select Factory Path. Check "Enable project specific settings" and then click "Add JARs…". Navigate to the project's
libs/folder and select the Butter Knife jar.
- Click "Ok" to save the new settings. Eclipse will ask you to rebuild your project to which you should click "Yes"
- Make sure that the
.apt_generated/folder is in your project root. It should contain files likeYOURACTIVITY$$ViewInjector.java. If these files are not present trigger a clean build by selected Project → Clean. This folder and files should not be checked into revision control. - Lastly, under "Java Compiler", make sure that the Compiler compliance level is set to Java version 1.6 at minimum.
使用ButterKnife无法inject view的解决办法的更多相关文章
- android.view.WindowLeaked解决办法
08-07 14:51:28.129: E/WindowManager(22277): Activity com.xxx.xxx.xxx.xxx.LoginActivity has leaked wi ...
- 使用Base SDK 6.1编译的APP在iOS7的设备上运行,NavigationBar覆盖view的解决办法
if (__IPHONE_OS_VERSION_MAX_ALLOWED <= __IPHONE_6_1) { self.navigationController.navigationBar.tr ...
- MarkdownPad 2 在win10下出错:HTML 渲染错误(This view has crashed) 的解决办法 + MarkdownPad2.5 注册码
首先附上MarkdownPad2.5的注册码. 邮箱:Soar360@live.com 授权密钥: GBPduHjWfJU1mZqcPM3BikjYKF6xKhlKIys3i1MU2eJHqWGImD ...
- IOS 开发中 Whose view is not in the window hierarchy 错误的解决办法
在 IOS 开发当中经常碰到 whose view is not in the window hierarchy 的错误,该错误简单的说,是由于 "ViewController" ...
- android 自定义view中findViewById为空的解决办法
网上说的都是在super(context, attrs);构造函数这里少加了一个字段, 其实根本不只这一个原因,属于view生命周期的应该知道,如果你在 自定义view的构造函数里面调用findVie ...
- Android中View类OnClickListener和DialogInterface类OnClickListener冲突解决办法
Android中View类OnClickListener和DialogInterface类OnClickListener冲突解决办法 如下面所示,同时导入这两个,会提示其中一个与另一个产生冲突. 1i ...
- no drawer view found with gravity RIGHT(Android实现侧滑菜单从右面滑出) 解决办法
代码如下: <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width ...
- UIScrollView上面放一个UIScrollView或者UITableView拖动时候 View出现一闪一闪解决办法
在项目中发现一个问题: 创建一个UIScrollView 上面放一个scrollView或者TableView,拖动scrollview或TableView 画面出现一闪一闪的情况. 解决办法设置一下 ...
- View not attached to window manager crash 的解决办法
View not attached to window manager crash 的解决办法 转自:http://stackoverflow.com/questions/22924825/view- ...
随机推荐
- 【转】linux建立软链接
实例:ln -s /home/gamestat /gamestat linux下的软链接类似于windows下的快捷方式 ln -s a b 中的 a 就是源文件,b是链接文件名,其作用是当进入 ...
- 矩阵求逆c++达到
高斯消元法能够用来找出一个可逆矩阵的逆矩阵.设A 为一个N * N的矩阵,其逆矩阵可被两个分块矩阵表示出来.将一个N * N单位矩阵 放在A 的右手边,形成一个N * 2N的分块矩阵B = [A,I] ...
- Fizz-Buzz-Whizz
Fizz-Buzz-Whizz ThoughtWorks测试 问题描述: 1. 你首先说出三个不同的特殊数,要求必须是个位数,比如3.5.7. 2. 让所有学生拍成一队,然后按顺序报数. 3. 学生报 ...
- mapxtreme演示V1.3
mapxtreme演示V1.3 mapxtreme地图相关基本功能的演示其中包括 鹰眼地图,图层控制,发达,缩小,平移地图,地图模糊查询,中点工具,距离测量工具,面积测量工具,图元信息查看工具,各 ...
- hadoop-mapreduce在maptask执行分析
MapTask执行通过执行.run方法: 1.生成TaskAttemptContextImpl实例,此实例中的Configuration就是job本身. 2.得到用户定义的Mapper实现类,也就是m ...
- 如何成功实施SDL提供的官方Android平台Demo
如何成功实施SDL提供的官方Android平台Demo 作者:雨水 日期:2014-4-30 编写说明:SDL的官方提供了一个Anroid的demo模板SDLActivity,无法直接执行,依照官方 ...
- 并发队列ConcurrentLinkedQueue和阻塞队列LinkedBlockingQueue用法(转)
在Java多线程应用中,队列的使用率很高,多数生产消费模型的首选数据结构就是队列(先进先出).Java提供的线程安全的Queue可以分为阻塞队列和非阻塞队列,其中阻塞队列的典型例子是BlockingQ ...
- ubuntu 下安装 matplotlib
直接使用sudo easy_install matplotlib 报错 ================================================================ ...
- 【web开发学习笔记】Structs2 Action学习笔记(两)
action学习笔记2-大约action method讨论 Action运行的时候并不一定要运行execute方法,能够在配置文件里配置Action的时候用method=来指定运行哪个方法 也能够在u ...
- SharePoint 2013 添加Ribbon菜单
原文:SharePoint 2013 添加Ribbon菜单 前言:今天,我们尝试一下添加SharePoint2013的Ribbon菜单,这个Ribbon菜单是由XML定义,JavaScript脚本来实 ...