说是Module中的R文件下的id不是final的。然后Butterknife就不行。。。
估计别的注解类型的也不好使吧。。。于是乎有什么办法么。。
详见:https://github.com/JakeWharton/butterknife/issues/100
以下是作者JakeWharton在14年12月的原话。。。
Yes this is not supported. This is a tradeoff between ease-of-use and what I tolerate as a sane API.
The only way to accomplish something like this is to allow string values like this:
@InjectView(name = "content_frame") protected FrameLayout
contentFrame; The downside's to this are:The downside's to this are:
It's not rename-safe or compile-safe (kind of). If you open the layout XML for this and do an IDE-backed rename operation it will not catch this string and update it. It also means you can (technically) compile the above code if there is no content_frame ID that exists. Now the compilation will eventually fail because the generated code will become invalid.
It's hard to know what R class to reference in the generated code, especially when you take into consideration the fact that you can use references to IDs that exist in libraries that you are referencing.
It forces us to have defaults for both the value and name properties on each annotation which means you can write @InjectView Foo foo and Butter Knife will have to fail the builder rather than javac.
Because of these facts, I have chosen not to support library projects.
One way that this could potentially be solved is to use a Gradle plugin rather than an annotation processor. I don't have the time to explore something like that for a few months though.
Android 스튜디오 Prettify
이 플러그인은 findViewById와 같은 콘텐츠를 자동으로 생성하므로 사용해 볼 수 있습니다.
버터나이프를 사용할 수 없다고 하셨습니다. 잘못 사용하고 있는 것일 수도 있으니 잘 확인해주세요.
모듈에 다른 내용은 없는 것 같으니 그냥 findViewById를 직접 사용하세요
이제는 버터나이프가 거의 필요하지 않습니다. BaseActivity 또는 BaseFragment에 직접 메서드를 캡슐화하기만 하면 됩니다
으아아아이것도 괜찮습니다. 더 많은 기능이 있습니다
https://github.com/excilys/androidannotations
ID를 찾으려면 시스템과 함께 제공되는 findviewyid를 사용하는 것이 가장 좋습니다.
RoboGuice? 아니면 안드로이드 주석?