一、控件和监听管理框架:butterknife
最新版本引用:
//黄油刀
implementation 'com.jakewharton:butterknife:10.2.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.1'
除此之外可以在安装插件:Android ButterKnife Zelezny :此插件可以一键绑定需要的控件和点击事件
二、数据库框架 ROOM
最新版本引用:
//ROOM
def room_version = "2.2.3"
implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"// For Kotlin use kapt instead of annotationProcessor
新建room文件夹,里面放dao、entity、database文件夹;
entity:实体类对应数据库中表;
类上加注释:@entity(tableName = "表名") ;
字段上加注释:@PrimaryKey、@ColumnInfo(name = "字段名");
dao:存放表查询接口;
接口上加注释:@Dao;
接口方法上加注释: 查询 @Query("select * from 表")
插入 @Insert
删除 @Delete
更改 @Update
databa:创建的数据库,继承 RoomDatabase;
类上加注释:@Database(entities = {实体类.class},version = 版本号,exportSchema = false)//exportSchema:默认true
类中是获取各个dao接口抽象方法和表升级时的Migration,例如:
public static final Migration MIGRATION_1_2 = new Migration(1,2) {
@Override
public void