我有一个FirebaseAdapter
,我想将我的Firebase数据检索到RecyclerView,但是使用这些代码,Logcat上没有任何错误,也没有任何内容,但是当我运行时页面是空的。我写错了什么?
ExpenseReceiptHistoryFragment
final String userId = FirebaseAuth.getInstance().getCurrentUser().getUid();
mdatabase = FirebaseDatabase.getInstance().getReference().child("Mavis").child("Scan").child(userId);
receiptHist = (RecyclerView) v.findViewById(R.id.receiptHist);
receiptHist.setHasFixedSize(true);
receiptHist.setLayoutManager(new LinearLayoutManager(getActivity()));
mFirebaseAdapter = new FirebaseRecyclerAdapter<ExpenseReceiptHistory, ExpenseReceiptHistoryFragment.ReceiptViewHolder>(ExpenseReceiptHistory.class, R.layout.fragment_expense_historyrow, ReceiptViewHolder.class, mdatabase) {
@Override
protected void populateViewHolder(ExpenseReceiptHistoryFragment.ReceiptViewHolder viewHolder, ExpenseReceiptHistory model, int position) {
viewHolder.setAccount(model.getAccount());
viewHolder.setAmount(model.getAmount());
viewHolder.setCategory(model.getCategory());
viewHolder.setCompany(model.getCompany());
viewHolder.setDate(model.getDate());
}
};
receiptHist.setAdapter(mFirebaseAdapter);
ReceiptViewHolder
public static class ReceiptViewHolder extends RecyclerView.ViewHolder {
View mView;
public ReceiptViewHolder(View itemView) {
super(itemView);
mView = itemView;
}
public void setAccount(String account){
TextView paymentText = (TextView) mView.findViewById(R.id.paymentText);
paymentText.setText(account);
}
public void setAmount(String amount){
TextView amountText = (TextView) mView.findViewById(R.id.amountText);
amountText.setText(amount);
}
public void setCategory(String category){
TextView categoryText = (TextView) mView.findViewById(R.id.categoryText);
categoryText.setText(category);
}
public void setCompany(String company){
TextView companyText = (TextView) mView.findViewById(R.id.companyText);
companyText.setText(company);
}
public void setDate(String date){
TextView dateText = (TextView) mView.findViewById(R.id.dateText);
dateText.setText(date);
}
}