-1

I am trying to link a list to a Category for each car with the use of Firebase, but saddly when I login to the application the Categories and the Cars fail to appear and all I am left with is a blank Screen.

[Database is Here][1]

Error Log

  E/RecyclerView: No adapter attached; skipping layout

Home Activity

package com.cars.evd.dealership.main;

import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Adapter;
import android.widget.TextView;
import android.widget.Toast;

import com.cars.evd.dealership.main.Common.Common;
import com.cars.evd.dealership.main.Interface.ItemClickListener;
import com.cars.evd.dealership.main.Model.Category;
import com.cars.evd.dealership.main.ViewHolder.CarViewHolder;
import com.cars.evd.dealership.main.ViewHolder.DealershipViewHolder;
import com.firebase.ui.database.FirebaseRecyclerAdapter;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.squareup.picasso.Picasso;

public class Home extends AppCompatActivity
        implements NavigationView.OnNavigationItemSelectedListener {

    FirebaseDatabase database;
    DatabaseReference category;
    TextView txtFullName;

    //Load Menu
    RecyclerView recycler_menu;
    RecyclerView.LayoutManager layoutManager;

    //Firebase Adapter
    FirebaseRecyclerAdapter<Category,CarViewHolder> adapter;




    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_home);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        toolbar.setTitle("Menu");
        setSupportActionBar(toolbar);
Rui
  • 9
  • 1
  • Possible duplicate of [recyclerview No adapter attached; skipping layout](https://stackoverflow.com/questions/29141729/recyclerview-no-adapter-attached-skipping-layout) – Zoe May 28 '18 at 20:30
  • Checked the answers but didnt solve it. I believe it has something to do with the values among the fields, but I cant be sure. I have tried all the possibilities but without much success. – Rui May 28 '18 at 20:40

1 Answers1

0

E/RecyclerView: No adapter attached; skipping layout

This is because you haven't initialize the adapter and add it to the RecyclerView when you don't find any CarCategoryID:

//Get intent here
if(getIntent() != null)
    CarCategoryID = getIntent().getStringExtra("CarCategoryID");

// here is the problem
if(!CarCategoryID.isEmpty() && CarCategoryID !=null){
    loadCarsList(CarCategoryID);
}

when you checking string with CarCategoryID.isEmpty() it will also check if the string is contain only "". Because you initializing the CarCategoryID and you don't have any intent, the loadCarsList method won't be called and you won't attach the adapter.

ישו אוהב אותך
  • 28,609
  • 11
  • 78
  • 96