Мой firebaserecyclerView не отображается в приложении, но данные добавляются в структуру firebase
Вот моя структура Firebase
Мне нужно отобразить название и итоговую сумму расходов в обзоре переработчика
Основная деятельность
public class DayExpensesActivity extends AppCompatActivity {
private RecyclerView recyclerView;
FirebaseDatabase firebaseDatabase;
DatabaseReference databaseReference;
FirebaseRecyclerAdapter<Expenses,ExpenseViewHolder> firebaseRecyclerAdapter;
RecyclerView.LayoutManager layoutManager;
Query query;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_day_expenses);
recyclerView=(RecyclerView)findViewById(R.id.recyclerView);
layoutManager=new LinearLayoutManager(this);
recyclerView.setLayoutManager(layoutManager);
firebaseDatabase=FirebaseDatabase.getInstance();
databaseReference=firebaseDatabase.getReference();
final Expenses expensesDate = new Expenses(username, monthyr, currentdate);
query=databaseReference.child("users").child(expensesDate.getUsername()).child(expensesDate.getMonth()).child(expensesDate.getDate());
FirebaseRecyclerOptions<Expenses> options =
new FirebaseRecyclerOptions.Builder<Expenses>()
.setQuery(query, Expenses.class)
.build();
firebaseRecyclerAdapter=new FirebaseRecyclerAdapter<Expenses, ExpenseViewHolder>(options) {
@Override
protected void onBindViewHolder(@NonNull ExpenseViewHolder holder, int position, @NonNull Expenses model) {
holder.expensesText.setText(model.getExpenseName());
holder.totaltext.setText(model.getTotal());
@NonNull
@Override
public ExpenseViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view=LayoutInflater.from(parent.getContext()).inflate(R.layout.expenses_card_layout,parent,false);
return new ExpenseViewHolder(view);
}
};
firebaseRecyclerAdapter.notifyDataSetChanged();
recyclerView.setAdapter(firebaseRecyclerAdapter);
ExpensesViewHolder
public class ExpenseViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
public TextView expensesText,totaltext;
public ImageButton addBtn,editBtn;
private ItemClickListener itemClickListener;
public void setItemClickListener(ItemClickListener itemClickListener){
this.itemClickListener=itemClickListener;
}
public ExpenseViewHolder(View itemView) {
super(itemView);
expensesText=(TextView) itemView.findViewById(R.id.expensestext);
totaltext=(TextView) itemView.findViewById(R.id.totaltxt);
addBtn=(ImageButton)itemView.findViewById(R.id.add_btn);
editBtn=(ImageButton)itemView.findViewById(R.id.btn_edt);
itemView.setOnClickListener(this);
}
@Override
public void onClick(View v) {
itemClickListener.onClick(v,getAdapterPosition(),false);
}
}