Use Debugger to check if you are getting data from firebase database? Or try to Init your Adaptor in OnCreateview method and use notifydatasetchanged()
You have to set Adapter inside onCreateView
then when new data arrives simply call adapter to notifyDataSetChaged
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View v = inflater.inflate(R.layout.fragment_temp, container, false);
youradapter = new TempAdapter(getContext(),new ArrayList<TempModel>());
rcv = (RecyclerView) v.findViewById(R.id.recycle_template);
rcv.setAdapter();
rcv.setLayoutManager(new GridLayoutManager(getContext(),3));
rcv.setHasFixedSize(true);
fireAdapter();
return v;
}
Then inside onDataChange
callback
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
for (DataSnapshot postSnapshot : dataSnapshot.getChildren()){
TempModel tempModel = postSnapshot.getValue(TempModel.class);
tempData.add(tempModel);
}
TempAdapter tempAdapter = new TempAdapter(getContext(),tempData);
yourAdapter.setData(tempData);
}
Then inside your TempAdapter
class create setData
function
public void setData(List<TempModel> list) {
if (data != null) data.clear();
if (data == null) data = new ArrayList<>();
data.addAll(list);
notifyDataSetChanged();
}