Android注入框架butterknife

开源地址:https://github.com/JakeWharton/butterknife

参考:

1.http://www.jianshu.com/p/4f7338ef806e

2.http://blog.csdn.net/itjianghuxiaoxiong/article/details/50177549

 

ButterKnife 是在编译时注解,不会在运行时产生负担,Build工程后你会发现它生成了需要的代码,即它不是使用反射或者在运行时生成代码,所以它不会导致任何性能问题,也不会影响应用速度。

 

使用心得:

1.Activity ButterKnife.bind(this);必须在setContentView();之后,且父类bind绑定后,子类不需要再bind

2.Fragment ButterKnife.bind(this, mRootView);

3.属性布局不能用private or static 修饰,否则会报错

4.setContentView()不能通过注解实现。(其他的有些注解框架可以)

 

1. 替代findViewById()

2. 设置监听

 

posted @ 2017-04-03 00:34  ryan_ys  阅读(235)  评论(0编辑  收藏  举报