Android注入框架butterknife

開源地址:https://github.com/JakeWharton/butterknifegit

參考:github

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

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

 

ButterKnife 是在編譯時註解,不會在運行時產生負擔,Build工程後你會發現它生成了須要的代碼,即它不是使用反射或者在運行時生成代碼,因此它不會致使任何性能問題,也不會影響應用速度。性能

 

使用心得:ui

1.Activity ButterKnife.bind(this);必須在setContentView();以後,且父類bind綁定後,子類不須要再bindthis

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

3.屬性佈局不能用private or static 修飾,不然會報錯blog

4.setContentView()不能經過註解實現。(其餘的有些註解框架能夠)it

 

1. 替代findViewById()

2. 設置監聽

相關文章
相關標籤/搜索