当我尝试从recyclerview调用user1时,它崩溃了,我想尝试解决它几个小时,但是如果仍然无法解决,那么如果您能帮助我,我会提出申请
private void readChats() {
users = new ArrayList<>();
reference = FirebaseDatabase.getInstance().getReference("teacher");
reference.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
users.clear();
for (DataSnapshot snapshot : dataSnapshot.getChildren()) {
User user = snapshot.getValue(User.class);
for (String id : usersList) {
if (user.getId().equals(id)) {
if (users.size() != 0) {
for (User user1 : users) {
if (!user.getId().equals(user1.getId())) {
users.add(user);
}
}
}else {
users.add(user);
}
}
}
}
userAdapter = new UserAdapter(getContext(), users);
recyclerView.setAdapter(userAdapter);
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
}
日志猫向我显示此代码for (User user1 : users)
上的错误
预先感谢