我是Android的初級用戶,我想在listView
中顯示錶格。我的表poster
包含三個字段:image
,status
和username
。我試過這段代碼,但我有這個錯誤,我在stackoverflow搜索,但我沒有找到這種類型的錯誤,我認爲這個問題在image
字段,謝謝。java.lang.NoClassDefFoundError:android/media/Image android/firebase
java.lang.NoClassDefFoundError: android/media/Image
at java.lang.Class.getDeclaredFields(Native Method)
at java.lang.Class.getPublicFieldsRecursive(Class.java:846)
at java.lang.Class.getFields(Class.java:829)
at com.google.android.gms.internal.zzbtg$zza.<init>(Unknown Source)
at com.google.android.gms.internal.zzbtg.zzi(Unknown Source)
at com.google.android.gms.internal.zzbtg.zze(Unknown Source)
at com.google.android.gms.internal.zzbtg.zzb(Unknown Source)
at com.google.android.gms.internal.zzbtg.zza(Unknown Source)
at com.google.firebase.database.DataSnapshot.getValue(Unknown Source)
at com.example.root.guidetouristique.PosteGestion$1.onChildAdded(PosteGestion.java:36)
at com.google.android.gms.internal.zzbox.zza(Unknown Source)
at com.google.android.gms.internal.zzbqx.zzZV(Unknown Source)
at com.google.android.gms.internal.zzbra$1.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: android.media.Image
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at java.lang.Class.getDeclaredFields(Native Method)
at java.lang.Class.getPublicFieldsRecursive(Class.java:846)
at java.lang.Class.getFields(Class.java:829)
at com.google.android.gms.internal.zzbtg$zza.<init>(Unknown Source)
at com.google.android.gms.internal.zzbtg.zzi(Unknown Source)
at com.google.android.gms.internal.zzbtg.zze(Unknown Source)
at com.google.android.gms.internal.zzbtg.zzb(Unknown Source)
at com.google.android.gms.internal.zzbtg.zza(Unknown Source)
at com.google.firebase.database.DataSnapshot.getValue(Unknown Source)
at com.example.root.guidetouristique.PosteGestion$1.onChildAdded(PosteGestion.java:36)
我在PosteGestion.java
代碼:
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
Post p = dataSnapshot.getValue(Post.class);
if(p!=null){
affichage.add(p);
}
else{
DR=FBD.getReference();
return;
}
}
Post.java
public class Post {
public Image image;
public String userName;
public String imagePost;
public String status ;
public Post(String userName, String imagePost, String status) {
this.userName = userName;
this.imagePost = imagePost;
this.status = status;
}
public Post(Image image, String userName, String imagePost, String status) {
this.image = image;
this.userName = userName;
this.imagePost = imagePost;
this.status = status;
}
public Post(String userName, String status) {
this.userName = userName;
this.status = status;
}
public Post() {
this.image=null;
this.imagePost=null;
this.userName=null;
this.status=null;
}
@Override
public String toString() {
return "Post{" +
"image=" + image +
", userName='" + userName + '\'' +
", imagePost='" + imagePost + '\'' +
", status='" + status + '\'' +
'}';
}
}
你能編輯你的問題來顯示Post.java的內容嗎? –