我有一些功能齐全的代码行来检索每个数据,但无法使用类检索它们。例如:这些线路运行良好。double value = (double) ds.child("player1score").getValue();long value = (long) ds.child("point").getValue();但是,在使用类检索时,会发生错误。这是我的代码的全貌,不确定它是否足以解决问题,请随时让我知道还需要什么,非常感谢您的建议,谢谢!Round().classpublic class Round {public double player1score;public double player2score;public double player3score;public double player4score;public long point;//Constructorpublic Round(double player1score, double player2score, double player3score, double player4score, long point) { this.player1score = player1score; this.player2score = player2score; this.player3score = player3score; this.player4score = player4score; this.point = point;//Below are All the getter and setter etc}我的 MainActivity.class.onCreate()//Declare VariablesUserId = FirebaseAuth.getInstance().getCurrentUser().getUid();DatabaseReference rootRef = FirebaseDatabase.getInstance().getReference();DatabaseReference gameInfoRef = rootRef.child("user").child(UserId).child("gameInfo");DatabaseReference gameRecordRef = rootRef.child("user").child(UserId).child("gameRecord");String gameKey = "-LLyXhetqj9mj5fgh9bn";在 onCreate() 下:gameRecordRef.child(gameKey).addValueEventListener(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { for (DataSnapshot ds : dataSnapshot.getChildren()) { ListView lv_history = (ListView) findViewById(R.id.lv_history); ArrayList<Round> ResultList = new ArrayList<>(); //This line is where the error pointed to Round round = (Round) ds.getValue(Round.class); ResultList.add(round); ivd_HistoryAdapter adapter = new ivd_HistoryAdapter(id_History.this, ResultList); lv_history.setAdapter(adapter); } }
添加回答
举报
0/150
提交
取消