草庐IT

Butterknife

全部标签

android - ButterKnife 如何使用带参数的@OnClick

我有一个TextView并通过调用setItem设置文本publicvoidsetItem(Stringtext){commentsTextView.setText(text);}有了butterknife应该是这样的:privateStringmText;publicvoidsetItem(Stringtext){mText=text;}@OnClick(R.id.commentsTextView)protectedvoidcomment(){commentsTextView.setText(mText);}但这看起来不对。使用@OnClick的正确方法是什么,而不仅仅是像所有示例所

java - butterknife 中的方法 "onClick"不起作用?

这是MainActivity:packagecom.example.a10648.demo;importandroid.os.Bundle;importandroid.support.v7.app.AppCompatActivity;importandroid.widget.Button;importandroid.widget.Toast;importbutterknife.BindView;importbutterknife.ButterKnife;importbutterknife.OnClick;publicclassMainActivityextendsAppCompatAc

java - 在 Android Studio 中导入 Butterknife 后注解 @InjectView 不工作?

最近刚接触到butterknife。我在我的gradle(module:app)文件中添加了这一行:编译'com.jakewharton:butterknife:7.0.1'它同步没有任何错误。我可以将“butterknife.Butterknife”导入到我通常导入的类文件中。但是cantimportbutterknife.InjectView好像没有?有什么建议吗? 最佳答案 Butterknife7.0.0版本包含重命名注释动词的重大更改。这在变更日志中突出显示并反射(reflect)在网站中。Version7.0.0*(20

java - 为什么我在 Android Studio 3.0 中出现 'com.jakewharton:butterknife:7.0.1' 的问题?

当我运行“app”(Androidstudio模拟器)时遇到以下问题:Error:Executionfailedfortask':app:javaPreCompileDebug'.>Annotationprocessorsmustbeexplicitlydeclarednow.Thefollowingdependenciesonthecompileclasspatharefoundtocontainannotationprocessor.PleaseaddthemtotheannotationProcessorconfiguration.-butterknife-7.0.1.jar(c

android - 在 Android Studio 和 Android 5.0 中使用 ButterKnife 失败

我使用butterknife用androidstudio开发我的应用程序并在android4.4上测试,它运行良好。但是当我在android5.0以上的手机上测试它时,它总是抛出如下错误。Causedby:java.lang.RuntimeException:Unabletobindviewsforcom.quinn.githubknife.ui.activity.MainActivityatbutterknife.ButterKnife.bind(ButterKnife.java:322)atbutterknife.ButterKnife.bind(ButterKnife.java:

android - Butterknife 如何从不同的 View 绑定(bind) View

在我的项目中我有这种情况:@BindView(R.id.viewpager)ViewPagerviewPager;TabLayouttabLayout;AddParkingFragmentListenerlistener;publicViewonCreateView(LayoutInflaterinflater,ViewGroupcontainer,BundlesavedInstanceState){ViewinflatedView=inflater.inflate(R.layout.fragment_add_parking,container,false);ButterKnife.b

Android Studio 1.0.0 - 未能找到 butterknife :6. 0.0

我正在使用AndroidStudio1.0.0。我正在尝试添加butterknife的依赖项。dependencies{compilefileTree(dir:'libs',include:['*.jar'])compile'com.android.support:appcompat-v7:21.0.3'compile'com.jakewharton:butterknife:6.0.0'compile'com.google.android.gms:play-services:6.1.11'compile'com.android.support:recyclerview-v7:21.0.

android - android 4.2 中的 Butterknife Nullpointer 异常

在我当前的项目中使用Butterknife;它在Kitkat和lollipop上运行良好,但在jellybean(4.2)上抛出空指针异常。在这一行抛出异常(btnLogin为NULL)btnLogin.setTypeface(FontsHelper.robotoRegular(this));Activity代码publicclassLoginextendsActivity{@Bind(R.id.btnLogin)FButtonbtnLogin;@Bind(R.id.btnRegister)FButtonbtnRegister;@Bind(R.id.edtEmail)EditTexte

android - 使用 ButterKnife 访问导航标题元素

我有一个处理从RecyclerView中选择字符的类,一切正常,但我想用正确的信息更新NavigationViewheader中元素的文本。到目前为止,我一直在尝试使用ButterKnife来解决这个问题,但没有成功。但是,我已经能够以这种方式使其工作:privateImageViewmImageView;privateTextViewTitlemTextViewName;privateTextViewRegularmTextViewTitle;privatestaticViewmHeaderView;publicvoidsetHeaderView(ViewheaderView){mH

android - ButterKnife onClick 自定义 View

我创建了一个自定义按钮并尝试使用ButterKnife@onClick注释,但它不起作用。是否可以为这样的自定义View使用ButterKnife,或者我将不得不使用默认的onClickListener?自定义按钮publicclassCustomButtonextendsRelativeLayout{publicCustomButton(Contextcontext){super(context);}publicCustomButton(Contextcontext,AttributeSetattrs){super(context,attrs);init();}publicCusto