I have created an adapter which is working fine. Now, I need to get a count of the no of data items in the adapter. i am using the function getItemcount() ,but I am getting a 0 every time. ALso, I am using Firebase for handling my database.
final Firebase mRoot = new Firebase(FIREBASE_URL);
mPosts= mRoot.child("posts");
rvPosts.setHasFixedSize(true); //for performance improvement
rvPosts.setLayoutManager(new LinearLayoutManager(this)); //for vertical list
postAdapter = new FirebaseRecyclerAdapter<Hello, PostViewHolder>(Hello.class, R.layout.view_hello, PostViewHolder.class, mPosts.orderByChild("postedBy")) {
@Override
protected void populateViewHolder(final PostViewHolder postViewHolder, final Hello hello, int i) {
//do something
}
};
rvPosts.setAdapter(postAdapter);
int postForSelect = postAdapter.getItemCount();
What can be the problem?