How to Implement Butterknife.Action in AndroidX?

五迷三道 提交于 2019-12-25 01:12:25

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!