RecyclerView doesn't load data in first launch using FirebaseRecyclerAdapter

前端 未结 2 1841
执笔经年
执笔经年 2021-01-22 03:36

I\'m using FirebaseRecyclerAdapter to populate a RecyclerView in a Fragment.

Here\'s my code

mDatabase = Firebase         


        
2条回答
  •  囚心锁ツ
    2021-01-22 03:49

    In your activity.xml file, set ProgressBar property

    android:visibility="invisible"

    and in your populateViewHolder method, set mProgress.setVisibility(View.GONE); after setting data to TextViews & ImageView

     protected void populateViewHolder(ProductViewHolder viewHolder, Product model, int position) {
            viewHolder.name.setText(model.name);
            viewHolder.price.setText(model.price);
            Glide.with(getActivity()).load(model.imageUri).into(viewHolder.thumbnail);
            mProgress.setVisibility(View.GONE);
            Log.d("NAME", model.name);
        }
    

提交回复
热议问题