butterknife

Android ButterKnife

梦想的初衷 提交于 2019-12-02 09:37:05
I've installed ButterKnife my build.gradle looks like this: dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.3.0' compile 'com.jakewharton:butterknife:8.4.0' } My loginActivity looks like this: package com.example.egen.forum; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.Toast; import butterknife.ButterKnife; import butterknife.OnClick; public class LoginActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) {

Android: Why do we need to use R2 instead of R with butterknife?

对着背影说爱祢 提交于 2019-12-01 17:03:20
I've been using butterknife for a few months and I've just noticed in its documentation that it says: Now make sure you use R2 instead of R inside all Butter Knife annotations. Why is that? I've been using R and everything works perfect. Using R2 is only necessary for building Android Library projects. https://github.com/JakeWharton/butterknife#library-projects It has to do with fact that the values in the R.java generated class aren't declared as "final" when built as part of a library. The annotations used for @BindView() need these R. values to be final and not subject to change later on. I

Android: Why do we need to use R2 instead of R with butterknife?

只愿长相守 提交于 2019-12-01 15:25:18
问题 I've been using butterknife for a few months and I've just noticed in its documentation that it says: Now make sure you use R2 instead of R inside all Butter Knife annotations. Why is that? I've been using R and everything works perfect. 回答1: Using R2 is only necessary for building Android Library projects. https://github.com/JakeWharton/butterknife#library-projects It has to do with fact that the values in the R.java generated class aren't declared as "final" when built as part of a library.

butterknife @OnClick inside ViewHolder in CustomAdapter

杀马特。学长 韩版系。学妹 提交于 2019-12-01 04:44:11
问题 I'm currently learning butterknife, and I need to bind specific @OnClicks on different views generated by my customer adapter. How do I go about with this? I've seen an answer in one of the questions here saying that he uses '@onclick' inside the 'ViewHolder'. I'm not sure how to implement this exactly. Any ideas? Thanks! 回答1: Imagine you have a ViewHolder like this. static class ViewHolder { @InjectView(R.id.user_name) TextView userName; @InjectView(R.id.user_title) TextView userTitle;

use of multiple <include /> tags in layout with ButterKnife

对着背影说爱祢 提交于 2019-12-01 03:50:40
I have a layout where I include the same sub-layout multiple times, each one with a different role: <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal"> <include android:id="@+id/settings_eco_seekarc" android:layout_width="match_parent" android:layout_height="match_parent" layout="@layout/settings_arc" /> <include android:id="@+id/settings_comfort_seekarc" android:layout_width="match_parent" android:layout_height="match_parent" layout="@layout/settings_arc" /> </LinearLayout> It works if I find the views in this way: View eco

Unable to find method 'com.android.build.gradle.api.BaseVariant.getOutputs()Ljava/util/List;'

只愿长相守 提交于 2019-12-01 03:50:12
build.gradle buildscript { ext.kotlin_version = '1.1.51' repositories { jcenter() mavenCentral() maven { url "https://jitpack.io" } } dependencies { classpath 'com.android.tools.build:gradle:3.0.0' classpath 'me.tatarka:gradle-retrolambda:3.6.1' classpath 'com.google.gms:google-services:3.1.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } app/build.gradle buildscript { repositories { jcenter() } dependencies { classpath 'com.jakewharton:butterknife-gradle-plugin:8.7.0' } } android{ compileSdkVersion = 26 buildToolsVersion = "26.0.2" defaultConfig { minSdkVersion =

Android ButterKnife插件

给你一囗甜甜゛ 提交于 2019-11-30 18:38:27
1.在在build.gradle 中添加如下两行代码 implementation 'com.jakewharton:butterknife:8.8.1' annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1' 2.点sync Now 3.打开Android Studio 的settings,在Plugins中搜索ButterKnife,点击安装(我已经安装完成),安装完需要重启AS 4.出现 Unknown host 'd29vzk4ow07wi7.cloudfront.net'. You may need to adjust the proxy settings in Gradle.错误,解决如下: 修改项目根目录下的 build.gradle 在 google() 下添加阿里云的镜像 maven{ url'http://maven.aliyun.com/nexus/content/groups/public/'} 5编译一下错误就没有了。 6.右击MainActivity中的active_main 然后就完成了,具体一些用法可以参考 https://blog.csdn.net/zyw0101/article/details/80399225 来源: https://www.cnblogs.com

Butterknife Fragment Button not working

♀尐吖头ヾ 提交于 2019-11-30 17:49:27
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 = inflater.inflate(R.layout.foo, container, false); ButterKnife.inject(this, view); return view; } @OnClick(R.id.some_btn) public void someButtonOnClick() { // do something } } However, the someButtonOnClick method is never called when the button is tapped on the screen. Thoughts on what I am doing wrong with the Butterknife framework? Here is the layout that is being used: <?xml

lateinit property has not been initialized

拜拜、爱过 提交于 2019-11-30 17:14:10
I have a custom linearlayout class and when I want to create instance of this class, I got an error lateinit property has not been initialized I'm using the latest version of butterknife library this is my kotlin class class MenuItemView : LinearLayout { @BindView(R.id.menu_title_text_view_id) lateinit var menuTitleTextView : CTextBasic constructor(ctx: Context) : super(ctx) { } init { val view = LayoutInflater.from(context).inflate(R.layout.menu_item,this) ButterKnife.bind(this,view) } constructor(ctx: Context, attrs: AttributeSet) : super(ctx, attrs) { val menuAttrs = context.theme

Butterknife View injection

笑着哭i 提交于 2019-11-30 17:07:01
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 title; @InjectView(R.id.subtitle) TextView subtitle; @InjectView(R.id.footer) TextView footer; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_activity); ButterKnife.inject(this); // TODO Use "injected" views... } } However if using Dependency Injection those Views must be