Android Butterknife的使用(黃油刀的使用)


github網址:https://github.com/JakeWharton/butterknife 中有詳細配置

app的build.gradle

android {
  ...
  // Butterknife requires Java 8. compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } } dependencies { implementation 'com.jakewharton:butterknife:10.2.1' annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.1' }

project中的build.gradle

buildscript {
  repositories {
    mavenCentral()
    google()
   }
  dependencies {
    classpath 'com.jakewharton:butterknife-gradle-plugin:10.2.1' } }

自己在android studio中安裝一個插件就可以右鍵生成

Activity中使用    ButterKnife.bind(this);

fragment中使用   bind = ButterKnife.bind(this, view);//this不能變···寫死就完了

adapter中使用  在viewholder中使用

  public ViewHolder(View view)

    ButterKnife.bind(this, view);

  } 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM