问题
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'
implementation 'com.jakewharton:butterknife:10.0.0' annotationProcessor 'com.jakewharton:butterknife-compiler:10.0.0'
回答1:
I used the latest version of ButterKnife (10.2.1). Follow these steps and the problem will be fixed.
//Step 1 : import this line
import butterknife.Action;
//Step 2 : in Scope Class
butterknife.Action viewAction = new Action()
{
@Override public void apply(@NonNull View view, int index)
{
// do something.
}
};
//Step 3 : ButterKnife.apply() in new version is deprecated . Replace to:
butterknife.ViewCollections.run(listView , viewAction );
回答2:
With androidX
, you should use
import butterknife.ButterKnife;
and then do something like new butterknife.Action<View>()
Package name is now butterknife
with a 'b'
whereas before if was with a 'B'
I hope this will help ...
来源:https://stackoverflow.com/questions/56754430/how-to-implement-butterknife-action-in-androidx