windows 10 pro office 2019 pro office 365 pro windows 10 home windows 10 enterprise office 2019 home and business office 2016 pro windows 10 education visio 2019 microsoft project 2019 microsoft project 2016 visio professional 2016 windows server 2012 windows server 2016 windows server 2019 Betriebssysteme office software windows server https://softhier.com/ instagram takipçi instagram beğeni instagram görüntüleme instagram otomatik beğeni facebook beğeni facebook sayfa beğenisi facebook takipçi twitter takipçi twitter beğeni twitter retweet youtube izlenme youtube abone instagram

RecyclerView shows only one item

Asked By: Anonymous

Im trying to display info from firebase firestore, but I get only one record in Recycleview. I do not know the reason of this. I have multiple records in my firestore collection, but only first one in list is returned/displayed.

public class fragment_history extends Fragment {
private final String TAG = "err";
private FirestoreRecyclerAdapter adapter;

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    return inflater.inflate(R.layout.fragment_history, container, false);
}

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    
    RecyclerView firestoreList = view.findViewById(R.id.recycler_view);
    
    FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
    FirebaseFirestore firebaseFirestore = FirebaseFirestore.getInstance();
    String userId = Objects.requireNonNull(user).getUid();
    
    Query query = firebaseFirestore.collection("user").document(userId).collection("prod1").limit(10);
    FirestoreRecyclerOptions<ProductModel> options = new FirestoreRecyclerOptions.Builder<ProductModel>()
            .setQuery(query, ProductModel.class)
            .build();
    
    adapter = new FirestoreRecyclerAdapter<ProductModel, ProductViewHolder>(options) {
        @NonNull
        @Override
        public ProductViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
            View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.display_item, parent, false);
            return new ProductViewHolder(view);
        }

        @SuppressLint("SetTextI18n")
        @Override
        protected void onBindViewHolder(@NonNull ProductViewHolder holder, int position, @NonNull ProductModel model) {
            holder.product_name.setText(model.getName());
            holder.product_price.setText(model.getPrice() + "");
        }
    };

    firestoreList.setHasFixedSize(true);
    firestoreList.setAdapter(adapter);

}
private static class ProductViewHolder extends RecyclerView.ViewHolder {
    private final TextView product_name;
    private final TextView product_price;

    public ProductViewHolder(@NonNull View itemView) {
        super(itemView);

        product_name = itemView.findViewById(R.id.product_name);
        product_price = itemView.findViewById(R.id.product_price);
    }

}

@Override
public void onStop() {
    super.onStop();
    adapter.stopListening();
}

@Override
public void onStart() {
    super.onStart();
    adapter.startListening();
}
}

LIST XML

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">


    <androidx.recyclerview.widget.RecyclerView
        app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/recycler_view" />

</RelativeLayout>

ITEM XML

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp">
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/product_name"
    android:text="item1name"/>
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/product_price"
    android:text="item1price"/>

I though this was because of list xml layout_height, but if I set it to wrap_content, then list is empty. Can you please help?


Solution

Answered By: Anonymous

The item.xml has LinearLayout height like match_parent android:layout_height="match_parent" which is wrong. Change it to wrap_content and it will solve the problem.

techinplanet staff

Porno Gratuit Porno Français Adulte XXX Brazzers Porn College Girls Film érotique Hard Porn Inceste Famille Porno Japonais Asiatique Jeunes Filles Porno Latin Brown Femmes Porn Mobile Porn Russe Porn Stars Porno Arabe Turc Porno caché Porno de qualité HD Porno Gratuit Porno Mature de Milf Porno Noir Regarder Porn Relations Lesbiennes Secrétaire de Bureau Porn Sexe en Groupe Sexe Gay Sexe Oral Vidéo Amateur Vidéo Anal

Windows 10 Kaufen Windows 10 Pro Office 2019 Kaufen Office 365 Lizenz Windows 10 Home Lizenz Office 2019 Home Business Kaufen windows office 365 satın al follower kaufen instagram follower kaufen porno