Butterknife: Library Project onClick is not available

Created on 20 Jul 2016  ·  2Comments  ·  Source: JakeWharton/butterknife

I have do with "Library projects" to config!but onClick is not available on my library for "aar":
the logcat without printing

@OnClick({R2.id.m_button_pattern, R2.id.m_button_password})
    public void onClick(View view) {
        Log.d("xx", "========onClick=========");
        Intent intent = new Intent();
        switch (view.getId()) {
            case R2.id.m_button_pattern:
                intent.setClass(getApplicationContext(),MainActivity.class);
                Log.d("xx", "========onClick====MainActivity=====");
                break;
            case R2.id.m_button_password:
                intent.setClass(getApplicationContext(),SetPasswordLockActivity.class);
                Log.d("xx", "========onClick=====SetPasswordLockActivity====");
                break;
        }
        this.startActivity(intent);
    }

Most helpful comment

You should use normal R.id. references in the runtime code (aka your method). This means you cannot use a switch, so use if/else instead.

All 2 comments

You should use normal R.id. references in the runtime code (aka your method). This means you cannot use a switch, so use if/else instead.

@JakeWharton Thanks

Was this page helpful?
0 / 5 - 0 ratings