android studio 3.6.3 使用 butterknife 插件 配合 butterknife 10.2.1

這是一個插件,方便自動進行findViewById 的操作。

1. 先安裝 File - Settings - Plugins - 搜索 Android ButterKnife Zelezny,然後安裝重啓。如果不能安裝成功,可以手動下載,手動從disk安裝。

2. 在 module 的 build.gradle 添加:

implementation 'com.jakewharton:butterknife:10.2.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.1'

3. 可以在layout的xml裏邊,右鍵 Generate Android Code 進行自動生成 butterknife 代碼

4. 可以在Activity代碼中,右鍵 R.layout.xxx,Generate... 可以選擇 ButterKnife injections...

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章