问题描述
我无法在Andoidx中使用ButterKnife.Action,有人可以对如何在androidx中使用ButterKnife.Action提出任何建议吗?
I am not able to use ButterKnife.Action in andoidx, can someone give any suugestions on how to use ButterKnife.Action in androidx?
classpath'com.jakewharton:butterknife-gradle-plugin:9.0.0-rc2'
classpath 'com.jakewharton:butterknife-gradle-plugin:9.0.0-rc2'
实现'com.jakewharton:butterknife:10.0.0'subscriptionProcessor'com.jakewharton:butterknife-compiler:10.0.0'
implementation 'com.jakewharton:butterknife:10.0.0'annotationProcessor 'com.jakewharton:butterknife-compiler:10.0.0'
推荐答案
我使用了最新版本的ButterKnife(10.2.1).请按照下列步骤操作,问题将得到解决.
I used the latest version of ButterKnife (10.2.1).Follow these steps and the problem will be fixed.
//第1步:导入此行
import butterknife.Action;
//第2步:在作用域类中
//Step 2 : in Scope Class
butterknife.Action viewAction = new Action()
{
@Override public void apply(@NonNull View view, int index)
{
// do something.
}
};
//第3步:不建议使用新版本的ButterKnife.apply().替换为:
//Step 3 : ButterKnife.apply() in new version is deprecated . Replace to:
butterknife.ViewCollections.run(listView , viewAction );
这篇关于如何在AndroidX中实现Butterknife.Action?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!