0

FirebaseRecyclerAdapter - zeigt nur einen leeren Bildschirm, ich bekomme keine Fehler beim Kompilieren und keine Fehler beim Scrollen herum. Ich habe Adapter().startListening(); zum onStart hinzugefügt, ich habe Daten zu Firebase im orders Kind hinzugefügt. Ich wäre dankbar für jede Hilfe.FirebaseRecyclerAdapter füllt nicht Firebase.ui 3.1.2

ist hier mein FirebaseRecyclerAdapter,

private FirebaseRecyclerAdapter<Orders, OrderViewHolder> Adapter() 
{ 
    Query query = mDatabaseReference.limitToLast(50); 
    final FirebaseRecyclerOptions<Orders> options = 
      new FirebaseRecyclerOptions.Builder<Orders>() 
        .setQuery(query, Orders.class) 
        .build(); 

    return new FirebaseRecyclerAdapter<Orders, OrderViewHolder>(options) { 

     @Override 
     public OrderViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 
      View view = LayoutInflater.from(parent.getContext()) 
        .inflate(R.layout.order_single_layout, parent, false); 
      return new OrderViewHolder(view); 
     } 

     @Override 
     protected void onBindViewHolder(OrderViewHolder ViewHolder, int position, Orders orders) { 
      ViewHolder.setOrderID(orders.getOrder_id()); 
      ViewHolder.setProductName(orders.getProduct_name()); 
      ViewHolder.setStatus(orders.getStatus()); 
     }   
    }; 
} 

Mein Viewholder

public static class OrderViewHolder extends RecyclerView.ViewHolder 
{ 
    View mView; 
    private OrderViewHolder(View itemView) 
    { 
     super(itemView); 
     mView = itemView; 
    } 
    public void setOrderID(String orderID) 
    { 
     TextView orderIdTextView = (TextView) mView.findViewById(R.id.orderSingle_OrderIDTextView); 
     orderIdTextView.setText(orderID); 
    } 
    public void setStatus(String status) 
    { 
     TextView statusTextView = (TextView) mView.findViewById(R.id.orderSingle_StatusTextView); 
     statusTextView.setText(status); 
    } 
    public void setProductName(String productName) 
    { 
     TextView productNameTextView = (TextView) mView.findViewById(R.id.orderSingle_ProductNameTextView); 
     productNameTextView.setText(productName); 
    } 
} 

auf Create

@Override 
protected void onCreate(Bundle savedInstanceState) 
{ 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_orders); 

    mDatabaseReference = FirebaseDatabase.getInstance().getReference().child("orders"); 
    adapter = Adapter(); 
    mOrderList = (RecyclerView) findViewById(R.id.order_RecyclerView); 
    mLayoutManager = new LinearLayoutManager(this); 
    mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL); 
    mOrderList.setHasFixedSize(true); 
    mOrderList.setLayoutManager(mLayoutManager); 
    mOrderList.setAdapter(adapter); 

} 

activityOrder.xml

<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context="com.chat.OrdersActivity"> 

<android.support.v7.widget.RecyclerView 
    android:id="@+id/order_RecyclerView" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:scrollbars="vertical" 
    android:layout_alignParentEnd="true"> 
</android.support.v7.widget.RecyclerView> 

Die Messageview für jede Nachricht in den RecyclerView gehen soll

RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 

<TextView 
    android:id="@+id/orderSingle_ProductNameTextView" 
    style="@style/textView_style" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentTop="true" 
    android:layout_centerHorizontal="true" 
    android:layout_marginTop="15dp" 
    android:textColor="#000000" 
    android:text="Product" 
    android:textSize="18sp" /> 

<TextView 
    android:id="@+id/orderSingle_StatusTextView" 
    style="@style/textView_style" 
    android:text="Status" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignStart="@+id/orderSingle_ProductNameTextView" 
    android:layout_below="@+id/orderSingle_ProductNameTextView" 
    android:layout_marginTop="12dp" 
    android:textColor="#000000"/> 

<TextView 
    android:id="@+id/orderSingle_OrderIDTextView" 
    style="@style/textView_style" 
    android:text="order_id" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignStart="@+id/orderSingle_ProductNameTextView" 
    android:layout_below="@+id/orderSingle_StatusTextView" 
    android:layout_marginTop="12dp" 
    android:textColor="#000000" /> 

Antwort

1

Verstanden Arbeit zu beginnen, indem .setLifecycleOwner(this) zu

Zugabe
final FirebaseRecyclerOptions<Orders> options = 
     new FirebaseRecyclerOptions.Builder<Orders>() 
       .setQuery(query, Orders.class) 
       .build(); 

Keine Ahnung, warum es jetzt funktioniert, aber es tut

Verwandte Themen