title: Retrieva Data from Firebase for RecyclerView
body: <p>I create a recyclerView and i want to retrieve data from firebase and display it in recyclerview. I have create two models. <br>Check image for firebase
  <a href="https://i.stack.imgur.com/faTgv.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/faTgv.jpg" alt="enter image description here" /></a></p>
  <p>The order which contains id,price,productId,productName and quantity is from an another list.<br>
  I want for example setText in orderDetails the productName<br>
  I cannot take with the same way because is another list<br>
  I take correct address,datetimename and payment method.But when i take productName is null<br>
  <a href="https://i.stack.imgur.com/74PY0.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/74PY0.jpg" alt="enter image description here" /></a></p>
  <p>My Request Model is :<br></p>
  <pre><code>public class Request {
  
      private String name;
      private String address;
      private String total;
      private String datetime;
      private String paymentMethod;
      private List&lt;CoffeeOrder&gt; order;
  
  
      public Request() {
      }
  
      public Request(String name, String address, String total, String datetime, String paymentMethod, List&lt;CoffeeOrder&gt; order) {
          this.name = name;
          this.address = address;
          this.total = total;
          this.datetime = datetime;
          this.paymentMethod = paymentMethod;
          this.order = order;
      }
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      public String getAddress() {
          return address;
      }
  
      public void setAddress(String address) {
          this.address = address;
      }
  
      public String getTotal() {
          return total;
      }
  
      public void setTotal(String total) {
          this.total = total;
      }
  
      public String getDatetime() {
          return datetime;
      }
  
      public void setDatetime(String datetime) {
          this.datetime = datetime;
      }
  
      public String getPaymentMethod() {
          return paymentMethod;
      }
  
      public void setPaymentMethod(String paymentMethod) {
          this.paymentMethod = paymentMethod;
      }
  
      public List&lt;CoffeeOrder&gt; getOrder() {
          return order;
      }
  
      public void setOrder(List&lt;CoffeeOrder&gt; order) {
          this.order = order;
      }
  }
  </code></pre>
  <p>My CoffeeOrder Model is:<br></p>
  <pre><code>public class CoffeeOrder {
  
      private int ID;
      private String ProductId;
      private String ProductName;
      private String Quantity;
      private String Price;
  
      public CoffeeOrder() {
      }
  
  
      public CoffeeOrder(int ID, String productId, String productName, String quantity, String price) {
          this.ID = ID;
          ProductId = productId;
          ProductName = productName;
          Quantity = quantity;
          Price = price;
  
      }
  
  
      public int getID() {
          return ID;
      }
  
      public void setID(int ID) {
          this.ID = ID;
      }
  
      public String getProductId() {
          return ProductId;
      }
  
      public void setProductId(String productId) {
          ProductId = productId;
      }
  
      public String getProductName() {
          return ProductName;
      }
  
      public void setProductName(String productName) {
          ProductName = productName;
      }
  
      public String getQuantity() {
          return Quantity;
      }
  
      public void setQuantity(String quantity) {
          Quantity = quantity;
      }
  
      public String getPrice() {
          return Price;
      }
  
      public void setPrice(String price) {
          Price = price;
      }
  }
  </code></pre>
  <p>My adapter is: <br></p>
  <pre><code>public class UserOrderAdapter extends RecyclerView.Adapter&lt;UserOrderAdapter.UserOrderViewHolder&gt; {
  
      ArrayList&lt;Request&gt; myList;
      Context context;
      List&lt;CoffeeOrder&gt; coffeeList;
  
  
      public UserOrderAdapter(Context context, ArrayList&lt;Request&gt; myList,List&lt;CoffeeOrder&gt; coffeeList) {
          this.myList = myList;
          this.context = context;
          this.coffeeList = coffeeList;
      }
  
      @NonNull
      @Override
      public UserOrderViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
          View v = LayoutInflater.from(context).inflate(R.layout.order_item, parent, false);
          return new UserOrderViewHolder(v);
      }
  
      @Override
      public void onBindViewHolder(@NonNull UserOrderViewHolder holder, int position) {
  
          Request request = myList.get(position);
  
          holder.usernameText.setText(request.getName());
          holder.orderTotalPrice.setText(request.getTotal());
          holder.orderDate.setText(request.getDatetime());
          holder.paymentMethod.setText(request.getPaymentMethod());
  
  
          for(CoffeeOrder item:coffeeList) {
              holder.orderDetails.setText(item.getProductName());
          }
  
  
  
      }
  
      @Override
      public int getItemCount() {
          return myList.size();
      }
  
      public static class UserOrderViewHolder extends RecyclerView.ViewHolder {
  
          TextView usernameText, orderTotalPrice, orderDate, paymentMethod, orderDetails;
  
  
          public UserOrderViewHolder(View itemView) {
              super(itemView);
  
              usernameText = (itemView).findViewById(R.id.username_text);
              orderTotalPrice = (itemView).findViewById(R.id.order_total_price);
              orderDate = (itemView).findViewById(R.id.order_date);
              paymentMethod = (itemView).findViewById(R.id.payment_method);
              orderDetails = (itemView).findViewById(R.id.order_details);
  
  
          }
  
      }
  
  }
  </code></pre>
  <p>My activity is: <br></p>
  <pre><code>public class UserOrderActivity extends AppCompatActivity {
  
      RecyclerView recyclerOrders;
      private FirebaseDatabase db = FirebaseDatabase.getInstance();
      private DatabaseReference ref = db.getReference().child(&quot;Requests&quot;);
      private UserOrderAdapter adapter;
      private ArrayList&lt;Request&gt; list;
      private List&lt;CoffeeOrder&gt; coffeeList;
      Toolbar toolbar;
      TextView userOrderBlankText;
  
      GifImageView gifImageView;
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_user_order);
  
          toolbar = findViewById(R.id.toolbar);
          gifImageView = findViewById(R.id.order_giffy);
          userOrderBlankText = findViewById(R.id.user_order_blank_text);
  
          setSupportActionBar(toolbar);
          getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  
          recyclerOrders = findViewById(R.id.recycler_orders);
          recyclerOrders.setHasFixedSize(true);
          recyclerOrders.setLayoutManager(new LinearLayoutManager(this));
  
          list = new ArrayList&lt;&gt;();
          coffeeList = new ArrayList&lt;&gt;();
          adapter = new UserOrderAdapter(UserOrderActivity.this, list,coffeeList);
          recyclerOrders.setAdapter(adapter);
  
  
          ref.addValueEventListener(new ValueEventListener() {
              @Override
              public void onDataChange(@NonNull DataSnapshot snapshot) {
  
                  for(DataSnapshot dataSnapshot : snapshot.getChildren()){
                      Request request = dataSnapshot.getValue(Request.class);
                      list.add(request);
                  }
  
                  adapter.notifyDataSetChanged();
  
                  if (list.size() == 0) {
                      gifImageView.setVisibility(GifImageView.VISIBLE);
                      userOrderBlankText.setVisibility(View.VISIBLE);
                  }
              }
  
              @Override
              public void onCancelled(@NonNull DatabaseError error) {
  
              }
          });
  
      }
  }
  </code></pre>