butterknife

How to use ButterKnife inside adapter

时光总嘲笑我的痴心妄想 提交于 2019-12-04 17:33:44
问题 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<Warm> { Context context; public WarmSpinnerAdapter(Context context, int resource, Warm[] objects) { super(context, resource, objects); } @Override public View getView(int position, View convertView, ViewGroup parent) { View v = LayoutInflater.from(context).inflate(R.layout.item_spinner, null); return v; }

Create a custom Annotation ButterKnife

ぃ、小莉子 提交于 2019-12-04 17:15:36
I'm trying to create a custom listener Annotation to ButterKnife but I can't make it work. Here is my Annotation: @Target(ElementType.METHOD) @Retention(RetentionPolicy.CLASS) @ListenerClass( targetType = "com.maddogs.mymoney.views.CameraImageView", setter = "setCameraImageViewListener", type = "com.maddogs.mymoney.views.CameraImageViewListener", method = @ListenerMethod( name = "onCloseClick", parameters = {"com.maddogs.mymoney.views.CameraImageView"}, returnType = "boolean", defaultReturn = "true" ) ) public @interface OnCloseClick { int[] value() default { View.NO_ID }; } And my

Android Butterknife - binding in fragment

╄→尐↘猪︶ㄣ 提交于 2019-12-04 14:59:55
问题 I'm using Butterknife for the first time but something must be wrong. I have a fragment and a Listview and a TextView just for testing but Butterknife wont bind my variables: public class MyFragment extends Fragment { @Bind(R.id.resultListView) ListView resultList; @Bind(R.id.textView1) TextView test; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_my, container, false); ButterKnife

Butterknife with Different Layouts for Phones and Tablets

醉酒当歌 提交于 2019-12-04 14:23:13
I am having a bit of an issue with using the Butterknife library in my current project. I am currently optimizing the project for both phones and tablets and there are sometimes slight differences between the layout files for the two for example layout/layout_example.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <TextView android:id="@+id/text1" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Text1/> </LinearLayout>

Subscriber not getting fired when using Otto

可紊 提交于 2019-12-04 12:15:46
I'm trying out Otto on Android and i'm trying to send back a message from my Fragment to the Activity. Here's the basics of my code: My Bus provider: public final class BusProvider { private static final Bus mInstance = new Bus(); private BusProvider() {} public static Bus getBusProviderInstance() { return mInstance; } } My Activity has the following code: public class MyActivity extends BaseActivity { // .... @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); BusProvider.getBusProviderInstance().register(this); // .... } @OnClick(R.id.profile_image

AndroidStudio disable “Expected resource of type string”

人走茶凉 提交于 2019-12-04 09:55:55
问题 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 @BindString, that is generated into something like that target.settings = res.getString(2131230792); How can I make studio not detect this as error? I've tried searching in settings, but without success. 回答1: This is reported on the GitHub project. It

Butter Knife return null pointer

不问归期 提交于 2019-12-03 23:21:28
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 LoginActivity extends AppCompatActivity implements LoginView, View.OnClickListener { @BindView(R.id.acEtUsername) AppCompatEditText userName; @BindView(R.id.acEtPassword) AppCompatEditText password; @BindView(R.id.prgCheckLogin) ProgressBar prgCheckLogin; @BindView(R.id.btnLogin) Button btnLogin; LoginPresenter loginPresenter; @Override protected void onCreate

Using ButterKnife library with 2 different views in 1 fragment

痴心易碎 提交于 2019-12-03 15:58:21
I'm currently trying to use the ButterKnife library for Android to handle some boilerplate code ( https://github.com/JakeWharton/butterknife ) I've got it set up, and got it semi-working, but i've run into a problem i can't fix :/ I have a Fragment which contains 1 single ListView element, and to this ListView i'm attaching a footer view which contains several elements. This is a code snippet from my fragment using the library: public class UsersFragment extends Fragment { @InjectView(R.id.users_listview_id) AutoUpdatingListView list; private View footerView; @InjectView(R.id.add_user_footer

Duplicate files while including butterknife with gradle

邮差的信 提交于 2019-12-03 14:33:30
问题 I have a basic Android app that I created with Android Studio, and I'm having problems adding butterknife to my build. I get this error: Error:: duplicate files during packaging of APK C:\apps\orion\app\build\apk\app-debug-unaligned.apk Error:Execution failed for task ':app:packageDebug'. > Duplicate files copied in APK META-INF/services/javax.annotation.processing.Processor File 1: C:\Users\andres\.gradle\caches\modules-2\files-2.1\com.jakewharton\butterknife\4.0.1