简体   繁体   English

在Butterknife上点击不起作用

[英]Onclick on Butterknife doesn't work

I'm new to Java and Butterknife, so I'm having some troubles. 我是Java和Butterknife的新手,所以我遇到了一些麻烦。 In this code, the function is logging that login button works, but I'm actually stuck because I see just nothing about my app's errors or this button's log. 在这段代码中,该函数记录了登录按钮的工作原理,但实际上我被卡住了,因为我看不到我的应用程序的错误或此按钮的日志。 I'm really confused and thanks for your help. 我真的很困惑,谢谢你的帮助。

Now, apt is Unknown dependency for AIDE. 现在,apt是AIDE的Unknown依赖。 That's my problem... 那是我的问题......

    @BindView(R.id.input_email) EditText _emailText;
    @BindView(R.id.input_password) EditText _passwordText;
    @BindView(R.id.btn_login) Button _loginButton;
    @BindView(R.id.link_signup) TextView _signupLink;
    @OnClick(R.id.btn_login) void logme(){
        login();
    }
    ... 
@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
        ButterKnife.bind(this);
    }
   .... 

public void login() {
        Log.d(TAG, "Login");
... 

Here comes project build.gradle 这是项目build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.+'
    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()
    }
}

Here comes subproject build.gradle 子项目build.gradle来了

apply plugin: 'com.android.application'
apply plugin: 'android-apt'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.0"

    defaultConfig {
        applicationId "dr.war.qpython.net"
        minSdkVersion 14
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile 'com.android.support:design:+'
    compile 'com.android.support:appcompat-v7:+'
    compile 'com.android.support:design:+'
    compile 'com.jakewharton:butterknife:8.1.0'
    apt 'com.jakewharton:butterknife-compiler:8.1.0'
    compile fileTree(dir: 'libs', include: ['*.jar'])
}

try adding the view in the function, replacing 尝试在函数中添加视图,替换

@OnClick(R.id.btn_login) void logme(){

with

@OnClick(R.id.btn_login) void logme(View view){

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM