I know there's a lot of similar questions like mine, but I've read and tried everything but still unable to solve this issue. What I am trying to achieve is to populate my listview with the data from the firebase. Im following a tutorial on youtube but Ive added some stuff, timestamp in particular. The error is in my for loop and says :
Class java.util.Map has generic type parameters, please use GenericTypeIndicator instead
This is my database looks like :
My Notes.java
public class Notes {
String noteId;
String noteCategory;
String note;
String rating;
public Map timeStamp;
public Notes(){
}
public Notes(String noteId, String noteCategory, String note, String rating, Map timeStamp) {
this.noteId = noteId;
this.noteCategory = noteCategory;
this.note = note;
this.rating = rating;
this.timeStamp = timeStamp;
}
public String getNoteId() {
return noteId;
}
public String getNoteCategory() {
return noteCategory;
}
public String getNote() {
return note;
}
public String getRating() {
return rating;
}
public Map<String,String> getTimeStamp() { return timeStamp;}
}
And below is my NoteList.java
@Override
protected void onStart() {
super.onStart();
databaseNotes.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
notesList.clear();
for(DataSnapshot noteSnapshot : dataSnapshot.getChildren()){
Notes notes = noteSnapshot.getValue(Notes.class);
notesList.add(notes);
}
NoteList adapter = new NoteList(MyNotes.this, notesList);
listViewNotes.setAdapter(adapter);
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
Any advice would be greatly appreciated! Thank you in advance.
EDIT : Okay, Ive tried the suggested answer, and after I logged the map it shows my data on the console. However, how do I iterate my map into the listview ?
Map<String, Object> map = (Map<String, Object>) dataSnapshot.getValue();