添加依赖:
implementation 'org.greenrobot:greendao:3.1.0'
implementation 'com.jakewharton:butterknife:8.5.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
implementation "com.daimajia.swipelayout:library:1.2.0@aar"
app中的build.gradle
apply plugin: 'com.android.application' apply plugin: 'org.greenrobot.greendao' android { compileSdkVersion 27 defaultConfig { applicationId "com.wanghuanlong.studentinformatica" minSdkVersion 22 targetSdkVersion 27 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } greendao { schemaVersion 1 targetGenDir 'src/main/java' } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:27.1.0' implementation 'com.android.support.constraint:constraint-layout:1.0.2' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.1' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' implementation 'org.greenrobot:greendao:3.1.0' implementation 'com.jakewharton:butterknife:8.5.1' annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1' implementation "com.daimajia.swipelayout:library:1.2.0@aar" }
model中
@Entity public class Student implements Serializable{ private String headSculpture;//头像 @Id private String stuid;//学号 private String ID;//身份证号码 @Property(nameInDb = "name") private String name;//姓名 private String age;//年龄 private Date datOfBirth;//出生日期 private String gender;//性别 private String fromClass;//班级 private String hobby;//爱好 private String EmotionalState;//情感状态 private String WordOfMouth;//口头禅 private String phone;//手机号 private String QQ;//QQ号 private String weichat;//微信 private String email;//电子邮箱 private String PhotosOfLife1;//生活照1 private String PhotosOfLife2;//生活照2 private String PhotosOfLife3;//生活照3 public String getPhotosOfLife1() { return PhotosOfLife1; } public void setPhotosOfLife1(String photosOfLife1) { PhotosOfLife1 = photosOfLife1; } public String getPhotosOfLife2() { return PhotosOfLife2; } public void setPhotosOfLife2(String photosOfLife2) { PhotosOfLife2 = photosOfLife2; } public String getPhotosOfLife3() { return PhotosOfLife3; } public void setPhotosOfLife3(String photosOfLife3) { PhotosOfLife3 = photosOfLife3; } private String detailedIntroduction;//详细介绍 private int NumberOfFans;//粉丝数 @Generated(hash = 167811149) public Student(String headSculpture, String stuid, String ID, String name, String age, Date datOfBirth, String gender, String fromClass, String hobby, String EmotionalState, String WordOfMouth, String phone, String QQ, String weichat, String email, String PhotosOfLife1, String PhotosOfLife2, String PhotosOfLife3, String detailedIntroduction, int NumberOfFans) { this.headSculpture = headSculpture; this.stuid = stuid; this.ID = ID; this.name = name; this.age = ag