Search code examples
javaandroiddependency-injectionbutterknife

Butterknife is not working with example


I saw the Butterknife tutorial and it states:

@BindViews({android.R.id.text1, android.R.id.text2})
TextView textEmail,description;

But it isn't working. And I also tried:

@BindViews(android.R.id.text1)
TextView textEmail;

@BindView(android.R.id.text2)
TextView description;

But it's not concise!


Solution

  • I think you might be binding the android ids rather than your view ids.

    Change android.R.id.text1 to R.id.yourText.

    To group views, you can group them into list/array:

    @BindViews({ R.id.first_name, R.id.middle_name, R.id.last_name })
    List<EditText> nameViews;
    

    Cheers~

    Source: http://jakewharton.github.io/butterknife/