I have a recycler view which is fetching data from the server and it is working fine. But I'm getting an error "No adapter attached; skipping layout" which I know I can solve this by setting an empty adapter. But this is important? It works without an empty adapter also.
Edit:-
I know how to fix that. I'm asking it is working without setting empty adapter. Why setting empty adapter is important?
My method which is setting up the recycler View.
private void setUpCategoryRecyclerView(List<Category> allCategories) {
final RecyclerView categoryListRecyclerView = (RecyclerView) getViewById(R.id.recyclerView);
final CategoryAdapter categoryAdapter = new CategoryAdapter(allCategories, false);
categoryAdapter.setOnItemClickListener(new CategoryAdapter.clickListener() {
@Override
public void onItemClick(int position, View v) {
final TextView CategoryName = v.findViewById(R.id.categoryName);
final Bundle bundle = new Bundle(); // Payload for next fragment
bundle.putString(CATEGORY, CategoryName.getText().toString());
FragmentsCallBack.CallBack(bundle);
}
});
categoryListRecyclerView.setLayoutManager(new LinearLayoutManager(context));
categoryListRecyclerView.setAdapter(categoryAdapter);
enableSearch(allCategories, categoryAdapter);
}