Reputation: 1384
So there are members and all of them submits fee at monthly basis so I created separate reference for their fee records to make structure more flat.
under the "fee" the top level keys are the keys of member to which the records belong, so that i can query records for specific memebers and then inside it there are fee records which have their own key, so how do i query only the fee records.
because it want to pull the only fees data in a FirebaseRecyclerAdaper what i have done so far is.
Query baseQuery = FireBaseHandler.getInstance(getActivity()).getFeeReference();
FirebaseRecyclerOptions<FeeRecord> options = new FirebaseRecyclerOptions.Builder<FeeRecord>()
.setLifecycleOwner(this)
.setQuery(baseQuery,FeeRecord.class)
.build();
mAdapter = new FirebaseRecyclerAdapter<FeeRecord,Holder>(options) {
@Override
protected void onBindViewHolder(@NonNull final Holder holder, int i, @NonNull FeeRecord feeRecord) {
}
@NonNull
@Override
public Holder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
LayoutInflater inflater = LayoutInflater.from(getActivity());
return new Holder(inflater,parent);
}
But the baseQuery here only return everything under fee and send them to recycler adapter but it is returning only two children , which you can see why in the structure above . How do i get feeRecords inside these two children and lay them in the recycler view.
Or do you recommend changing the structure
Thanks in advanace
Upvotes: 0
Views: 386
Reputation: 598728
The adapter in FirebaseUI are made to display a single flat list of data from the Realtime Database. So in your data model, they can either display the list of users (the nodes directly under /fees
), or the fees for one specific user (the nodes under one /fees/$pushid
).
The FirebaseUI adapters cannot display all nodes in a tree, or at least not without significant modification on your part.
I recommend:
ArrayList
, and then create a custom adapter to display the data from that list. For some inspiration for this, also see Android - Display data in ListView from Firebase database, Cast arraylist in recyclerview firebaseUpvotes: 1