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