Questions tagged [butterknife]

An annotation-based Android view "injection" framework aimed at reducing boilerplate.

View "injection" library for Android which uses annotation processing to generate boilerplate code for you.

  • Eliminate findViewById calls by using @Bind on fields.
  • Group multiple views in a list using @BindViews. Operate on all of them at once with actions, setters, or properties.
  • Eliminate anonymous inner-classes for listeners by annotating methods with @OnClick and others.

The documentation includes additional code examples and use cases.

ButterKnife is open sourced under Apache 2.0 license.

536 questions
30
votes
3 answers

@OnClick array with optional ids (ButterKnife)

I have an activity that inflates a view when a web request finished. Some of the widgets of this view have to be attached to one onClick method, so I have: @OnClick({R.id.bt1, R.id.bt2, R.id.inflated_bt1, R.id.inflated_bt2}) public void onClick(View…
victor.alm
  • 480
  • 1
  • 7
  • 16
29
votes
2 answers

RecyclerView.ViewHolder unable to bind view with ButterKnife

I'm using ButterKnife to bind my views on my ViewHolder. My code is below: public class MyAdapter extends RecyclerView.Adapter { private List data; public MyAdapter(List data) { …
KVISH
  • 12,923
  • 17
  • 86
  • 162
28
votes
5 answers

AndroidStudio disable "Expected resource of type string"

I've just tried to generate signed apk for one of my projects (I already did this before), but (maybe since updating Android Studio) I'm getting Error:Error: Expected resource of type string [ResourceType] This is because I'm using Butterknife's…
Yaroslav
  • 4,750
  • 3
  • 22
  • 33
26
votes
5 answers

ButterKnife onclick is not working

I injected views perfectly using butterknife library. But when I try to implement listeners, for example onclick I'm not able to implement them. Following java code will help you to understand my problem. Java code: public class LoginActivity…
malli
  • 642
  • 2
  • 12
  • 30
23
votes
5 answers

Using Butter Knife in Custom BaseAdapter SubClass Results in "Unable to inject views" error

I'm attempting to use Butter Knife to simplify creation of a custom BaseAdapter class. I'm following the example here: http://jakewharton.github.io/butterknife/ under the "Another use is simplifying the view holder pattern inside of a list…
reggie3
  • 1,018
  • 2
  • 15
  • 22
22
votes
1 answer

Butterknife View injection

I stumbled across a very interesting Dependency Injection library called ButterKnife. Using ButterKnife it's easily possible to inject Views into activities or fragments. class ExampleActivity extends Activity { @InjectView(R.id.title) TextView…
Moonlit
  • 5,171
  • 14
  • 57
  • 95
20
votes
12 answers

cannot find symbol class DaggerAppComponent or cannot find symbol class DaggerActivityComponent

I get this error after adding inject on my class then it gives me a compilation error. If I remove @Inject static ApiService mApiService; it's working fine And I'm using 2 Application class those are extended MultidexApplication because I have…
mbpatel
  • 501
  • 1
  • 5
  • 19
19
votes
6 answers

Butter Knife return null pointer

I want to using Butter Knife in my project.I did everything according to the Butter Knife tutorial. But when I set anything to the views (setText, setClickListener ...) I got null object reference exception. This is my code: public class…
FarshidABZ
  • 3,860
  • 4
  • 32
  • 63
18
votes
2 answers

Using Butterknife to inject an array of views

Currently I have this array of views: ImageView activityImageViews[] = { (ImageView) rootView.findViewById(R.id.img_activity_1), (ImageView) rootView.findViewById(R.id.img_activity_2), (ImageView)…
aluxian
  • 986
  • 10
  • 27
16
votes
2 answers

Using @OnCheckedChanged (ButterKnife) with radioGroup gives error in android

i recently integrated butterknife in my android project, and now i am trying to use @OnCheckedChanged annotation for radiogroup. but getting error of not giving callback. So what is the right method to call and get checkedId or this one is for…
Niki
  • 1,566
  • 1
  • 19
  • 36
16
votes
4 answers

Butterknife 8.4.0 does not find views after re-running the app. It gets a NullPointerException

After re-running the app in Android Studio Butterknife.bind(this) does not find the views anymore. The only reliable solution I found so far is by Cleaning/Rebuilding Project and run it again. Then it finds the views again until the next re-run.…
Murat Karagöz
  • 35,401
  • 16
  • 78
  • 107
16
votes
3 answers

Bind ButterKnife to Dialog fails

I try to bind ButterKnife to a AleterDialog that i made with a DialogBuilder method And exist this method ButterKnife.bind(Object,Dialog); but dosen't work for me import android.support.v4.app.DialogFragment; import…
Rolando Corratge Nieves
  • 1,233
  • 2
  • 10
  • 25
15
votes
1 answer

ButterKnife findByID method is deprecated in version 8.8.0

Hi I have just updated ButterKnife library version 8.7.0 to 8.8.0 compile 'com.jakewharton:butterknife:8.8.0' annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.0' and found that: findById(view, id); is deprecated, why? what method to…
Narek Hayrapetyan
  • 1,731
  • 15
  • 27
15
votes
2 answers

Butterknife is unable to bind inside my Adapter Class

I have an Adapter that draws the layouts for my Navigation Drawer. My navigation drawer contains two inner xml files: One being the Header and the other being the Row. I draw these out in a single adapter, but when I'm trying to setText() on my…
remedy.
  • 2,032
  • 3
  • 25
  • 48
14
votes
7 answers

Android Studio: Integrating Butterknife?

I am trying to implement Butterknife into my android studio project. However when I do so I get an error on @InjectView "cannot resolve symbol InjectView". Have I not implemented Butterknife sucsessfully? Activity code: package…
android99999
  • 143
  • 1
  • 1
  • 4
1
2
3
35 36