Process: com.example.berkbatuhangurhan.pollmanagerapp, PID: 313
com.google.firebase.database.DatabaseException: Class java.util.List has generic type parameters, please use GenericTypeIndicator instead
我已经搜索了有关我的问题的其他问题,但他们似乎没有工作。我试图从Firebase中检索我的Poll
对象并继续收到上面的消息;
我尝试过使用Lists,HashMaps,Generic类型的paramateres,但我没有运气。我在这里虽然有点欢迎任何帮助
DatabaseReference ref = FirebaseDatabase.getInstance().getReference("polls");
ref.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Poll p1=null;
for(DataSnapshot childSnapShot:dataSnapshot.getChildren()) {
p1=childSnapShot.getValue(Poll.class);
}
Poll post =dataSnapshot.getValue(Poll.class);
Toast.makeText(main_activity.this, "A= "+p1.getPollCreator(), Toast.LENGTH_SHORT).show();
}
您可以在下面找到我的民意调查课程:
public class Poll {
public String pollTitle;
public String pollCreatorEmail;
public Date dateCreated;
public List<Question> questions;
public Date deadLine;
public List<Integer> votes;
public int pollPrivacy;
public boolean pendStatus=false;
public Poll(String pollTitle, String pollCreatorEmail, int pollPrivacy,boolean pendStatus){
this.pollTitle=pollTitle;
this.pollCreatorEmail=pollCreatorEmail;
//this.dateCreated=dateCreated;
//this.questions=questions;
//this.deadLine=deadLine;
//this.votes=votes;
this.pollPrivacy=pollPrivacy;
this.pendStatus=pendStatus;
questions=new ArrayList<Question>();
votes=new ArrayList<Integer>();
}
public Poll(){}
public String getPollTitle(){
return pollTitle;
}
public void setPollTitle(String newTitle){
pollTitle=newTitle;
}
public String getPollCreator(){
return pollCreatorEmail;
}
public void setPollCreator(String pollCreatorEmail){
this.pollCreatorEmail=pollCreatorEmail;
}
// SKIPPED ATTRIBUTE METHODS
public List<Question> getQuestions(){
return questions;
}
public void setQuestions(List<Question> questions){
this.questions=questions;
}
public Date getDeadLine(){
return deadLine;
}
public void setDeadLine(Date newDeadLine){
deadLine=newDeadLine;
}
public void sharePoll(){
}
public void addQuestion(Question question){
questions.add(question);
}
public void deleteQuestion(Question question){
questions.remove(question);
}
public List<Integer> getVotes(){
return votes;
}
public void setVotes(Integer index){
votes.add(index,votes.get(index)+1);
}
public void votePoll(Question question){
//????????????????????????????
}
public void setPollPrivacy(int privacy){
pollPrivacy=privacy;
}
public int getPollPrivacy(){
return pollPrivacy;
}
}
我的数据库结构
-Polls -PollTitle1 -pollCreator -状态 -Questions -1 -qText -qNum -PollTitle2