我只能保存名称,但不能保存评级值,如下图所示:-
我的评分编码。供您参考,tuitionName是微调器类型,而tuitionRating是评级栏类型。我在tuitionRating的getSelectedItem上遇到了一个错误...应该为ratingBar放置什么?
private void createRating()
{
String uid = mAuth.getCurrentUser().getUid();
String tuitionname = mTuitionName.getSelectedItem().toString().trim();
String tuitionrating = mRatingBar.getSelectedItem().toString().trim();
Rates rates = new Rates(uid, tuitionname, tuitionrating);
mTuitionRates.child("Rates").child(uid).setValue(rates).addOnCompleteListener(new OnCompleteListener<Void>()
{
@Override
public void onComplete(@NonNull Task<Void> task)
{
if(task.isSuccessful())
{
//Toast.makeText(Signup.this, "Data has been added successfully.", Toast.LENGTH_SHORT).show();
}
else
{
Toast.makeText(RatingActivity.this, task.getException().getMessage(), Toast.LENGTH_SHORT).show();
}
}
});
}
最佳答案
解:
代替这个:
String tuitionrating = mRatingBar.getSelectedItem().toString().trim();
用这个:
String tuitionrating = String.valueOf(mRatingBar.getRating());
试试吧。希望它能工作。
关于java - 评级值未出现在我的Firebase数据库中,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/52550770/