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
13
votes
9 answers

Why is butterknife 9.0.0-SNAPSHOT not resolving?

I want using AndroidX library and below is my Gradle setup for Butterknife app:module Dependency implementation 'com.jakewharton:butterknife:9.0.0-SNAPSHOT' annotationProcessor 'com.jakewharton:butterknife-compiler:9.0.0-SNAPSHOT' Plugin apply…
Ismail
  • 445
  • 1
  • 5
  • 20
13
votes
3 answers

How to use ButterKnife inside adapter

I would like to use ButterKnife to bind my views inside listView adpater. I tried this, but i can not simply use my "spinner" var. public class WarmSpinnerAdapter extends ArrayAdapter { Context context; public…
Stepan
  • 1,041
  • 5
  • 23
  • 35
13
votes
4 answers

ButterKnife not working with Jack?

I just started a very simple project and tried to use both ButterKnife and Jack compiler, but it seems they do not cope with each other well. Gradle plugin version: 2.2.0-alpha5 in my module build.gradle I added: compile…
Marvin
  • 1,726
  • 1
  • 17
  • 25
13
votes
2 answers

Why ButterKnife uses a DebouncingOnClickListener for @OnClick methods?

I was looking at the generated code of ButterKnife, and noticed that for @OnClick annotations it is using a DebouncingOnClickListener, implemented by the library. What the DebouncingOnClickListener does it to avoid more than one click on any element…
13
votes
5 answers

The import butterknife.InjectView cannot be resolved

I am trying to use this library project, so I tried to run the sample application (in /app/source/main/ in the Github link), and in MainActivity.java, I am getting the error on the import import butterknife.InjectView; and also in…
Solace
  • 8,612
  • 22
  • 95
  • 183
13
votes
4 answers

How to use ButterKnife OnItemClick with RecyclerView?

As onItemClick is no more in RecyclerView, does ButterKnife still able to handle its item clicks with @onItemClick or with @onClick annotations? If not so, any work around to use that?
Silly Questions
  • 183
  • 1
  • 1
  • 12
13
votes
3 answers

Butterknife Fragment Button not working

I have a Fragment that I am using Butterknife with. public class FooFragment extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view =…
Perry Hoekstra
  • 2,687
  • 3
  • 33
  • 52
12
votes
0 answers

ButterKnife: Null views after Fragment recreation on a ViewPager

I'm working with the latest version of Butterknife (8.2.1) and I have a problem: I'm using a ViewPager with 3 Fragments, when the Fragment is recreated all views become null!! The first 2 Fragments, no problem, but when I swipe to the 3rd and go…
iroyo
  • 723
  • 7
  • 23
12
votes
1 answer

Butterknife bind SearchView from Menu

In my current Android project I use the Butterknife library to bind views and use onClick annotations for them. This all works great even in fragments but now I'm at the point where I can't find a solution: I use the new ToolBar as ActionBar and…
Cilenco
  • 6,951
  • 17
  • 72
  • 152
12
votes
2 answers

Robojuice / Butterknife @InjectView AutoFormatting issue in Android Studio

I am adopting the @InjectView theme throughout my project and have a minor issue when it comes to condensing these declarations. After I put in the initial code it looks great in one line like this.. @InjectView(R.id.tv_report_summary_name)…
AK824
  • 217
  • 3
  • 10
12
votes
2 answers

Butterknife Fragment Injecting Views Not Working?

Can anyone explain why my View element (ListView) is null with the following code: public class NewsFragment extends Fragment { @InjectView(R.id.news_listView) ListView lv; @Override public View onCreateView(LayoutInflater inflater, …
Aerial
  • 1,185
  • 4
  • 20
  • 42
11
votes
2 answers

How to setup ButterKnife plugin in Android Studio?

I need to install the plugin Butter Knife. Where can I download it? I downloaded a .jar plugin (but not if the file is the one I need), I have installed but when I click on the option "generate" not the option to use butterknife appears. following a…
Rafael Hernández
  • 354
  • 1
  • 2
  • 14
11
votes
4 answers

Butterknife custom view unbind

What's the best practice for calling : - Butterknife.unbind() in a custom Android view please?
aprofromindia
  • 1,111
  • 1
  • 13
  • 27
11
votes
2 answers

Why does Butterknife @Bind fail in release build (after proguard)

I've been building an Android app using Butterknife and recently upgraded to 7.0.1. I replaced all the @InjectView and ButterKnife.inject usage with the new @Bind feature and have no problems with debug builds but the app crashes on startup for…
Karl Nosworthy
  • 1,991
  • 1
  • 17
  • 16
10
votes
3 answers

How to get the TextInputLayout related to edit text?

I have many edit texts inside differents TextInputLayouts, How can i get the TextInputLayout where is the edit text i am working with? Example : @BindView(R.id.eT) EditText eT; @BindView(R.id.eT2) EditText…
1 2
3
35 36