【问题标题】:RecyclerView shows only two textview?others are not display...items are not displayingRecyclerView 仅显示两个文本视图?其他不显示...项目不显示
【发布时间】:2020-08-23 23:05:16
【问题描述】:

我遇到了一个问题,比如只显示了两个项目,其他两个项目没有显示,它们是联系的,平坦的,没有这个项目没有显示......我也尝试删除和添加其他文本视图,但通过这个只显示两个项目。 ...现在我想在似乎不起作用的 RecyclerView 上显示数据,我很确定我的代码很好,但有些东西似乎不起作用而且我找不到它。我也尝试stackoverflow 建议的所有事情,但什么都不会发生,所以我想我需要问...... 文件在这里

public class RecieptFP extends AppCompatActivity {
    private RecyclerView mFirestoreList;
    private FirebaseFirestore firebasefirestore;
    private FirestoreRecyclerAdapter adapter;
    Button Back;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_reciept_fp);
        Back = findViewById(R.id.btndashboard);

        firebasefirestore = FirebaseFirestore.getInstance();
        mFirestoreList = findViewById(R.id.firestore_list);

        //query
        Query query = firebasefirestore.collection("UserDataR");
        //RecyclerOptions
        FirestoreRecyclerOptions<RecieptModel> options = new FirestoreRecyclerOptions.Builder<RecieptModel>()
                .setQuery(query, RecieptModel.class)
                .build();
        adapter = new FirestoreRecyclerAdapter<RecieptModel, RecieptViewHolder>(options) {
            @NonNull
            @Override
            public RecieptViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
                View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.listsingleiteam, parent, false);
                return new RecieptViewHolder(view);
            }

            @Override
            protected void onBindViewHolder(RecieptViewHolder recieptViewHolder, int i, RecieptModel recieptModel) {
                recieptViewHolder.list_name.setText(recieptModel.getName());
                recieptViewHolder.list_amount.setText(recieptModel.getAmount());
                recieptViewHolder.list_contact.setText(recieptModel.getContact());
                recieptViewHolder.list_Flatno.setText(recieptModel.getFlatNo());
            }
        };
        //viewholder
        mFirestoreList.setHasFixedSize(false);
        mFirestoreList.setLayoutManager(new LinearLayoutManager(this));
        mFirestoreList.setAdapter(adapter);

        Back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent i1 = new Intent(RecieptFP.this, Dashboard.class);
                startActivity(i1);

            }
        });
    }


    private class RecieptViewHolder extends RecyclerView.ViewHolder {

        private TextView list_name;
        private TextView list_amount;
        private TextView list_contact;
        private TextView list_Flatno;

        public RecieptViewHolder(@NonNull View itemView) {
            super(itemView);
            list_name = itemView.findViewById(R.id.list_name);
            list_amount = itemView.findViewById(R.id.list_amount);
            list_contact = itemView.findViewById(R.id.list_contact);
            list_Flatno = itemView.findViewById(R.id.list_Flatno);
        }
    }

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

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

}

配方模型

package com.societypay;

public class RecieptModel {
    private  String Name;
    private  String Amount;
    private String Contact;
    private String FlatNo;

    private  RecieptModel(){}
    private RecieptModel(String Name,String Amount,String Contact,String FlatNo){
        this.Name=Name;
        this.Amount=Amount;
        this.Contact=Contact;
        this.FlatNo=FlatNo;
    }
    public String getName() {
        return Name;
    }

    public void setName(String name) {
        Name = name;
    }

    public String getAmount() {
        return Amount;
    }

    public void setAmount(String amount) {
        Amount = amount;
    }

    public String getContact() {
        return Contact;
    }

    public void setContact(String contact) {
        Contact = contact;
    }


    public String getFlatNo() {
        return FlatNo;
    }

    public void setFlatNo(String flatNo) {
        FlatNo = flatNo;
    }
}

【问题讨论】:

  • 请发布数据库结构
  • 请编辑您的问题并将您的数据库结构添加为屏幕截图和RecieptModel 课程的内容。请回复@AlexMamo
  • @AlexMamo 感谢您的回复我通过截图编辑这篇文章请解决这个问题
  • @Ashish 我通过数据库结构编辑这篇文章
  • @AlexMamo 感谢您的帮助,alex 我解决了这个问题...

标签: android firebase google-cloud-firestore android-recyclerview


【解决方案1】:

请使用以下pojo并尝试。

public class RecieptModel
{
    private String MobileNo;

    private String Amount;

    private String Flat_no;

    private String Name;

    public String getMobileNo ()
    {
        return MobileNo;
    }

    public void setMobileNo (String MobileNo)
    {
        this.MobileNo = MobileNo;
    }

    public String getAmount ()
    {
        return Amount;
    }

    public void setAmount (String Amount)
    {
        this.Amount = Amount;
    }

    public String getFlat_no ()
    {
        return Flat_no;
    }

    public void setFlat_no (String Flat_no)
    {
        this.Flat_no = Flat_no;
    }

    public String getName ()
    {
        return Name;
    }

    public void setName (String Name)
    {
        this.Name = Name;
    }

    @Override
    public String toString()
    {
        return "ClassPojo [MobileNo = "+MobileNo+", Amount = "+Amount+", Flat_no = "+Flat_no+", Name = "+Name+"]";
    }
}

【讨论】:

    猜你喜欢
    • 2023-03-25
    • 2019-05-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多