title: recyclerView E/RecyclerView: No adapter attached; skipping layout
body: <p>Don't know why it says &quot;No adapter attached&quot;</p>
  <p>I set the layout manager and the recycler view, in middle of showProducts(); method i also set the adapter to the recycler view and still says: &quot;No adapter attached&quot; Can't find where is the issue, i'll gladly accept some help. Thanks folks!</p>
  <p>Nothing shows on screen for the following code:</p>
  <p>Main activity:</p>
  <p>public class MainActivity extends AppCompatActivity {</p>
  <pre><code>private RecyclerView rView;
  private RecyclerView.LayoutManager layoutManager;
  private List&lt;Product&gt; products;
  private ProductAdapter productAdapter;
  private DatabaseReference mDataBase;
  private CardView cardView;
  
  
  
  
  //Product
  private String id;
  private String name;
  private String author;
  private String genre;
  private String description;
  private double  price;
  private int stock;
  private String image;
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      products = new ArrayList&lt;Product&gt;();
  
      mDataBase = FirebaseDatabase.getInstance().getReference();
      cardView = (CardView) findViewById(R.id.cardView);
  
      layoutManager = new LinearLayoutManager(this);
  
      rView = (RecyclerView) findViewById(R.id.recyclerView);
      rView.setHasFixedSize(true);
      rView.setLayoutManager(layoutManager);
  
  
  
      showProducts();
  
  
      registerForContextMenu(rView);
  
  }
  
  private void showProducts() {
  
      mDataBase.child(&quot;Products&quot;).addValueEventListener(new ValueEventListener() {
  
          @Override
          public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
  
              if (dataSnapshot.exists()) {
                  products.clear();
                  for (DataSnapshot ds : dataSnapshot.getChildren()) {
                      name = ds.child(&quot;title&quot;).getValue().toString();
                      author = ds.child(&quot;author&quot;).getValue().toString();
                      genre = ds.child(&quot;genre&quot;).getValue().toString();
                      description = ds.child(&quot;description&quot;).getValue().toString();
                      price = Double.parseDouble(ds.child(&quot;price&quot;).getValue().toString());
                      stock = Integer.parseInt(ds.child(&quot;stock&quot;).getValue().toString());
                      image = ds.child(&quot;image&quot;).getValue().toString();
                      id = ds.getKey();
  
                      Product product = new Product(id, name, author, genre, description, price, stock,  image);
                      products.add(product);
  
                  }
                  productAdapter = new ProductAdapter(products, R.layout.recycler_view, new ProductAdapter.OnItemClickListener() {
                      @Override
                      public void onItemClick(Product product, int position) {
  
  
  
                      }
                  }, new ProductAdapter.OnButtonClickListener() {
                      @Override
                      public void onButtonClick(Product product, int position) {
  
  
                      }
                  });
              }
              rView.setAdapter(productAdapter);
  
          }
              // Observa como pasamos el activity, con this. Podríamos declarar
              // Activity o Context en el constructor y funcionaría pasando el mismo valor, this
  
  
          @Override
          public void onCancelled(@NonNull DatabaseError databaseError) {
  
          }
  
  
      });
  
  
  }
  </code></pre>
  <p>}</p>
  <p>Adapter:</p>
  <p>public class ProductAdapter extends RecyclerView.Adapter&lt;ProductAdapter.ViewHolder&gt;{</p>
  <pre><code>private Context context;
  private List&lt;Product&gt; products;
  private int layout;
  private OnItemClickListener itemClickListener;
  private OnButtonClickListener btnClickListener;
  
  
  public ProductAdapter(List&lt;Product&gt; products, int layout, OnItemClickListener itemListener, OnButtonClickListener btnListener) {
      this.products = products;
      this.layout = layout;
      this.itemClickListener = itemListener;
      this.btnClickListener = btnListener;
  }
  
  @Override
  public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
      View v = LayoutInflater.from(parent.getContext()).inflate(layout, parent, false);
      context = parent.getContext();
      ViewHolder vh = new ViewHolder(v);
      return vh;
  }
  
  @Override
  public void onBindViewHolder(ViewHolder holder, int position) {
      holder.bind(products.get(position), itemClickListener, btnClickListener);
  }
  
  @Override
  public int getItemCount() {
      return products.size();
  }
  
  public class ViewHolder extends RecyclerView.ViewHolder {
  
      public TextView name;
      public TextView author;
      public TextView genre;
      public TextView description;
      public TextView price;
      public TextView stock;
      public ImageView image;
      public Button btnDelete;
  
  
      public ViewHolder(View itemView) {
          super(itemView);
          name = (TextView) itemView.findViewById(R.id.textViewProductName);
          author = (TextView) itemView.findViewById(R.id.textViewProductAuthor);
          genre = (TextView) itemView.findViewById(R.id.textViewProductGenre);
          description = (TextView) itemView.findViewById(R.id.textViewProductDescription);
          price = (TextView) itemView.findViewById(R.id.textViewProductPrice);
          stock = (TextView) itemView.findViewById(R.id.textViewProductStock);
          image = (ImageView) itemView.findViewById(R.id.imageViewProduct);
          btnDelete = (Button) itemView.findViewById(R.id.buttonDeleteCity);
      }
  
      public void bind(final Product product, final OnItemClickListener itemListener, final OnButtonClickListener btnListener) {
          name.setText(product.getName());
          description.setText(product.getDescription());
          price.setText((int) product.getPrice());
          Picasso.get().load(product.getImage()).fit().into(image);
  
          btnDelete.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  btnListener.onButtonClick(product, getAdapterPosition());
              }
          });
  
  
          itemView.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  itemListener.onItemClick(product, getAdapterPosition());
              }
          });
      }
  }
  
  public interface OnItemClickListener {
      void onItemClick(Product product, int position);
  }
  
  public interface OnButtonClickListener {
      void onButtonClick(Product product, int position);
  }
  </code></pre>
  <p>}</p>