zoukankan      html  css  js  c++  java
  • ButterKnife使用

    这个快速注解插件非常好用,但是要注意,本人在用的时候用它去onclick的时候报空指针异常下面说说怎么用。

    1.在file里面选择

    搞定之后,还需要在APP下的build.gradle

    apply plugin: 'com.android.application'
    apply plugin: 'com.neenbedankt.android-apt' //加这一句
    android {
        compileSdkVersion 25
        buildToolsVersion "25.0.2"
        defaultConfig {
            applicationId "com.example.administrator.myapplication0022"
            minSdkVersion 15
            targetSdkVersion 25
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }
    
    dependencies {
        compile fileTree(include: ['*.jar'], dir: 'libs')
        androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
            exclude group: 'com.android.support', module: 'support-annotations'
        })
        compile 'com.android.support:appcompat-v7:25.2.0'
        testCompile 'junit:junit:4.12'
        compile 'com.jakewharton:butterknife:8.0.1'
        apt 'com.jakewharton:butterknife-compiler:8.0.1'//加这一句
     }

    ,另外在项目的build.gradle里面

    buildscript {
        repositories {
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:2.2.0'
            classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'//加这一句
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }
    
    allprojects {
        repositories {
            jcenter()
        }
    }
    
    task clean(type: Delete) {
        delete rootProject.buildDir
    }

    这些都做完之后就可以快乐的使用注解和快速生成点击监听了,但有时候会generate会不出现butterknife这个插件选项,需要在File -> settings -> Plugins  -> Browse repositories -> 搜索ButterKnife,安装完成后restart,重启studio就可以用了

  • 相关阅读:
    ecos启动流程分析
    ecos中断机制分析(2)
    Redboot修改实例
    6/6 项目开工
    6/8 可配置工作流 实现思路
    6/7 第2次碰头
    6/10 主要流程和界面讨论会确定
    6/10 设计方案目录草案
    C# 获取某月的第一天和最后一天
    【Manage It】之掌控项目
  • 原文地址:https://www.cnblogs.com/laoyimou/p/6651885.html
Copyright © 2011-2022 走看看