因为AndroidAnnotations是自动构建了一个新的Activity
给重构代码带来很多的不方便
我推荐butterknife
引入方式:
//AndroidAnnotations
annotationProcessor "org.androidannotations:androidannotations:4.3.1"
compile group: 'org.androidannotations', name: 'androidannotations-api', version: '4.3.1'
//butterknife
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.0'
compile 'com.jakewharton:butterknife:8.8.0'
举例:butterknife
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:design:25.3.1'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.picasso:picasso:2.5.2'
//Gson
compile 'com.google.code.gson:gson:2.6.2'
//zxing
compile(project(':zxing-android-embedded')) { transitive = true }
//butterknife
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.0'
compile 'com.jakewharton:butterknife:8.8.0'
//test
testCompile 'junit:junit:4.12'
}
分享到:
相关推荐
除了基本的功能,AndroidAnnotations还支持与其他流行的Android库集成,如ButterKnife、Retrofit、Dagger等。这使得整个开发流程更加流畅,减少了许多繁琐的手动操作。 总的来说,AndroidAnnotations是一个强大的...
此外,它也可以与其他库如 Dagger、ButterKnife 等配合使用,实现更复杂的架构设计。 总之,AndroidAnnotations 是一个强大且实用的开发工具,它通过注解的方式简化了 Android 应用的开发过程,提高了代码质量和...
此外,AndroidAnnotations还支持依赖注入,如使用`@InjectView`注解,可以通过ButterKnife库实现视图注入,进一步简化了界面构建。同时,它提供的`@AfterViews`注解可以在所有视图绑定完成后执行代码块,方便进行...
3. **依赖注入**: 虽然AndroidAnnotations自身不包含完整的依赖注入解决方案,但可以很好地与其他库如Dagger、ButterKnife配合使用。 4. **兼容性**: 支持Android Studio和Gradle构建系统,以及Android的各个版本。...
与其他基于注释的库和框架兼容,例如ButterKnife、AndroidAnnotations、RoboGuice等,快速入门步骤 1 - 使用Saripaar Annotations注释你的小部件@NotEmpty@Emailprivate EditText emailEditText
这个库受到了 **ButterKnife** 和 **AndroidAnnotations** 的启发,提供了更加简洁、高效的编程体验。下面将详细探讨Android-SwissKnife的关键特性、如何使用以及它在实际开发中的优势。 1. **视图注入**: ...
它基于ButterKnife和AndroidAnnotations。 SwissKnife 使用SwissKnife可以实现: 1、在任意一个可以查找到的对象中自动的注入视图,无需继承任何的类; 2、在一些正在使用的动作中添加回调方法; 3、在UI线程或正在...
- `ButterKnife` 通过注解将视图和回调绑定到字段和方法。 - `Dagger2` 是Google的快速依赖注入框架,适用于Android和Java。 - `RoboGuice` 是针对Android的Google Guice实现。 - `AndroidAnnotations` 提供快速...