Firebase数据库的部分数据在recyclerview中不显示
Some data of Firebase databse is not displayed in recyclerview
我创建了一个应用程序并将一些数据存储在 firebase 数据库中。我想在 recyclerview 中显示数据,但所有数据都未填充,即显示 4 个字段的数据,但 recyclerview 未显示两个字段(血型和 phone 否)的数据。下面是我的代码。提前致谢
我的适配器 RcvAdapter
public class RcvAdapter extends FirebaseRecyclerAdapter<ModelClass, RcvAdapter.MyViewHolder> {
public RcvAdapter(@NonNull @NotNull FirebaseRecyclerOptions<ModelClass> options) {
super(options);
}
@Override
protected void onBindViewHolder(@NonNull @NotNull MyViewHolder holder, int position, @NonNull @NotNull ModelClass model) {
holder.uAddress.setText(model.getAddress());
holder.uBGroup.setText(model.getBloodGroup());
holder.uCity.setText(model.getCity());
holder.uDistrict.setText(model.getDistrict());
holder.uName.setText(model.getName());
holder.uPhone.setText(model.getPhoneNumber());
holder.uContact.setText(model.getContact());
}
@NonNull
@NotNull
@Override
public MyViewHolder onCreateViewHolder(@NonNull @NotNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.dashboard_rcv_layout, parent, false);
return new MyViewHolder(view);
}
class MyViewHolder extends RecyclerView.ViewHolder{
TextView uAddress;
TextView uBGroup;
TextView uCity;
TextView uDistrict;
TextView uName;
TextView uPhone;
TextView uContact;
public MyViewHolder(@NonNull @NotNull View itemView) {
super(itemView);
uAddress = (TextView) itemView.findViewById(R.id.rcv_address);
uBGroup =(TextView) itemView.findViewById(R.id.rcv_bloodGroup);
uCity =(TextView) itemView.findViewById(R.id.rcv_city);
uDistrict =(TextView) itemView.findViewById(R.id.rcv_district);
uName =(TextView) itemView.findViewById(R.id.rcv_name);
uPhone = (TextView) itemView.findViewById(R.id.rcv_phoneNumber);
uContact =(TextView) itemView.findViewById(R.id.rcv_contact);
}
}
Recyclerview单行布局
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView 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"
app:cardCornerRadius="5dp"
android:elevation="5dp"
app:cardUseCompatPadding="true"
android:layout_height="wrap_content">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/rcv_address"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:fontFamily="@font/roboto_light"
android:text="Lal colony"
android:textAlignment="center"
android:textColor="#070707"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="@+id/rcv_phoneNumber"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="@+id/rcv_phoneNumber"
app:layout_constraintTop_toBottomOf="@+id/rcv_phoneNumber" />
<TextView
android:id="@+id/rcv_district"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:fontFamily="@font/roboto_light"
android:text="Malakand"
android:textAlignment="center"
android:textColor="#070707"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="@+id/rcv_city"
app:layout_constraintStart_toStartOf="@+id/rcv_city"
app:layout_constraintTop_toBottomOf="@+id/rcv_city" />
<TextView
android:id="@+id/rcv_city"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:fontFamily="@font/roboto_light"
android:text="Thana"
android:textAlignment="center"
android:textColor="#070707"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="@+id/rcv_address"
app:layout_constraintStart_toStartOf="@+id/rcv_address"
app:layout_constraintTop_toBottomOf="@+id/rcv_address" />
<TextView
android:id="@+id/textView6"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:fontFamily="@font/roboto_medium"
android:text="Address"
android:textColor="#070707"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="@+id/textView3"
app:layout_constraintStart_toStartOf="@+id/textView3"
app:layout_constraintTop_toBottomOf="@+id/textView3" />
<TextView
android:id="@+id/textView9"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:fontFamily="@font/roboto_medium"
android:text="City"
android:textColor="#070707"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="@+id/textView6"
app:layout_constraintStart_toStartOf="@+id/textView6"
app:layout_constraintTop_toBottomOf="@+id/textView6" />
<TextView
android:id="@+id/textView7"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:fontFamily="@font/roboto_medium"
android:text="District"
android:textColor="#070707"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="@+id/textView9"
app:layout_constraintStart_toStartOf="@+id/textView9"
app:layout_constraintTop_toBottomOf="@+id/textView9"
/>
<TextView
android:id="@+id/rcv_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="50dp"
android:layout_marginTop="8dp"
android:fontFamily="@font/roboto_light"
android:text="User Name"
android:textAlignment="center"
android:textColor="#070707"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/textView"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/rcv_bloodGroup"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="32dp"
android:fontFamily="@font/roboto_light"
android:text="Blood Group"
android:textAlignment="center"
android:textColor="#070707"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="@+id/rcv_name"
app:layout_constraintStart_toStartOf="@+id/rcv_name"
app:layout_constraintTop_toBottomOf="@+id/rcv_name" />
<TextView
android:id="@+id/rcv_phoneNumber"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:fontFamily="@font/roboto_light"
android:text="+923005658587"
android:textAlignment="center"
android:textColor="#070707"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@+id/rcv_name"
app:layout_constraintTop_toBottomOf="@+id/rcv_bloodGroup" />
<TextView
android:id="@+id/rcv_contact"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:fontFamily="sans-serif-medium"
android:text="Contact"
android:textAlignment="center"
android:textColor="#2196F3"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView7" />
<TextView
android:id="@+id/textView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="250dp"
android:fontFamily="@font/roboto_medium"
android:text="Name"
android:textColor="#070707"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textView2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:fontFamily="@font/roboto_medium"
android:text="Blood Group"
android:textColor="#070707"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="@+id/textView"
app:layout_constraintStart_toStartOf="@+id/textView"
app:layout_constraintTop_toBottomOf="@+id/textView" />
<TextView
android:id="@+id/textView3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:fontFamily="@font/roboto_medium"
android:text="Phone No"
android:textColor="#070707"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="@+id/textView2"
app:layout_constraintStart_toStartOf="@+id/textView2"
app:layout_constraintTop_toBottomOf="@+id/textView2" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
我的 MainActivity
public class DashboardActivity extends AppCompatActivity {
RecyclerView recyclerView;
RcvAdapter adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dashboard);
recyclerView = findViewById(R.id.recyclerView);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
// database = FirebaseDatabase.getInstance().getReference().child("Users");
// Retrive firebase data into recyclerview
FirebaseRecyclerOptions<ModelClass> options =
new FirebaseRecyclerOptions.Builder<ModelClass>()
.setQuery(FirebaseDatabase.getInstance().getReference().child("Users"), ModelClass.class)
.build();
adapter = new RcvAdapter(options);
recyclerView.setAdapter(adapter);
}
@Override
protected void onStart() {
super.onStart();
adapter.startListening();
}
@Override
protected void onStop() {
super.onStop();
adapter.stopListening();
}
模型类
public class ModelClass {
String address;
String bloodGroup;
String city;
String district;
String name;
String phoneNumber;
String contact;
public ModelClass() {
}
public ModelClass(String address, String bloodGroup, String city, String district, String name, String phoneNumber, String contact) {
this.address = address;
this.bloodGroup = bloodGroup;
this.city = city;
this.district = district;
this.name = name;
this.phoneNumber = phoneNumber;
this.contact = contact;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getBloodGroup() {
return bloodGroup;
}
public void setBloodGroup(String bloodGroup) {
this.bloodGroup = bloodGroup;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getDistrict() {
return district;
}
public void setDistrict(String district) {
this.district = district;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPhoneNumber() {
return phoneNumber;
}
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
public String getContact() {
return contact;
}
public void setContact(String contact) {
this.contact = contact;
}
}
血型数据和Phone没有填充。
DashboardActivity 布局
<androidx.constraintlayout.widget.ConstraintLayout 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:background="@color/dark_red"
tools:context=".DashboardActivity">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
由于您将默认 encoder/decoder 与 FirebaseRecycler class 一起使用,因此您应确保将数据库中的键名与模型中的键名相匹配。
例如,尝试将 ModelClass
中的“phoneNumber”更改为“phone”(与数据库相同)。
我创建了一个应用程序并将一些数据存储在 firebase 数据库中。我想在 recyclerview 中显示数据,但所有数据都未填充,即显示 4 个字段的数据,但 recyclerview 未显示两个字段(血型和 phone 否)的数据。下面是我的代码。提前致谢
我的适配器 RcvAdapter
public class RcvAdapter extends FirebaseRecyclerAdapter<ModelClass, RcvAdapter.MyViewHolder> {
public RcvAdapter(@NonNull @NotNull FirebaseRecyclerOptions<ModelClass> options) {
super(options);
}
@Override
protected void onBindViewHolder(@NonNull @NotNull MyViewHolder holder, int position, @NonNull @NotNull ModelClass model) {
holder.uAddress.setText(model.getAddress());
holder.uBGroup.setText(model.getBloodGroup());
holder.uCity.setText(model.getCity());
holder.uDistrict.setText(model.getDistrict());
holder.uName.setText(model.getName());
holder.uPhone.setText(model.getPhoneNumber());
holder.uContact.setText(model.getContact());
}
@NonNull
@NotNull
@Override
public MyViewHolder onCreateViewHolder(@NonNull @NotNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.dashboard_rcv_layout, parent, false);
return new MyViewHolder(view);
}
class MyViewHolder extends RecyclerView.ViewHolder{
TextView uAddress;
TextView uBGroup;
TextView uCity;
TextView uDistrict;
TextView uName;
TextView uPhone;
TextView uContact;
public MyViewHolder(@NonNull @NotNull View itemView) {
super(itemView);
uAddress = (TextView) itemView.findViewById(R.id.rcv_address);
uBGroup =(TextView) itemView.findViewById(R.id.rcv_bloodGroup);
uCity =(TextView) itemView.findViewById(R.id.rcv_city);
uDistrict =(TextView) itemView.findViewById(R.id.rcv_district);
uName =(TextView) itemView.findViewById(R.id.rcv_name);
uPhone = (TextView) itemView.findViewById(R.id.rcv_phoneNumber);
uContact =(TextView) itemView.findViewById(R.id.rcv_contact);
}
}
Recyclerview单行布局
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView 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"
app:cardCornerRadius="5dp"
android:elevation="5dp"
app:cardUseCompatPadding="true"
android:layout_height="wrap_content">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/rcv_address"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:fontFamily="@font/roboto_light"
android:text="Lal colony"
android:textAlignment="center"
android:textColor="#070707"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="@+id/rcv_phoneNumber"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="@+id/rcv_phoneNumber"
app:layout_constraintTop_toBottomOf="@+id/rcv_phoneNumber" />
<TextView
android:id="@+id/rcv_district"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:fontFamily="@font/roboto_light"
android:text="Malakand"
android:textAlignment="center"
android:textColor="#070707"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="@+id/rcv_city"
app:layout_constraintStart_toStartOf="@+id/rcv_city"
app:layout_constraintTop_toBottomOf="@+id/rcv_city" />
<TextView
android:id="@+id/rcv_city"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:fontFamily="@font/roboto_light"
android:text="Thana"
android:textAlignment="center"
android:textColor="#070707"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="@+id/rcv_address"
app:layout_constraintStart_toStartOf="@+id/rcv_address"
app:layout_constraintTop_toBottomOf="@+id/rcv_address" />
<TextView
android:id="@+id/textView6"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:fontFamily="@font/roboto_medium"
android:text="Address"
android:textColor="#070707"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="@+id/textView3"
app:layout_constraintStart_toStartOf="@+id/textView3"
app:layout_constraintTop_toBottomOf="@+id/textView3" />
<TextView
android:id="@+id/textView9"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:fontFamily="@font/roboto_medium"
android:text="City"
android:textColor="#070707"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="@+id/textView6"
app:layout_constraintStart_toStartOf="@+id/textView6"
app:layout_constraintTop_toBottomOf="@+id/textView6" />
<TextView
android:id="@+id/textView7"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:fontFamily="@font/roboto_medium"
android:text="District"
android:textColor="#070707"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="@+id/textView9"
app:layout_constraintStart_toStartOf="@+id/textView9"
app:layout_constraintTop_toBottomOf="@+id/textView9"
/>
<TextView
android:id="@+id/rcv_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="50dp"
android:layout_marginTop="8dp"
android:fontFamily="@font/roboto_light"
android:text="User Name"
android:textAlignment="center"
android:textColor="#070707"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/textView"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/rcv_bloodGroup"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="32dp"
android:fontFamily="@font/roboto_light"
android:text="Blood Group"
android:textAlignment="center"
android:textColor="#070707"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="@+id/rcv_name"
app:layout_constraintStart_toStartOf="@+id/rcv_name"
app:layout_constraintTop_toBottomOf="@+id/rcv_name" />
<TextView
android:id="@+id/rcv_phoneNumber"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:fontFamily="@font/roboto_light"
android:text="+923005658587"
android:textAlignment="center"
android:textColor="#070707"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@+id/rcv_name"
app:layout_constraintTop_toBottomOf="@+id/rcv_bloodGroup" />
<TextView
android:id="@+id/rcv_contact"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:fontFamily="sans-serif-medium"
android:text="Contact"
android:textAlignment="center"
android:textColor="#2196F3"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView7" />
<TextView
android:id="@+id/textView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="250dp"
android:fontFamily="@font/roboto_medium"
android:text="Name"
android:textColor="#070707"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textView2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:fontFamily="@font/roboto_medium"
android:text="Blood Group"
android:textColor="#070707"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="@+id/textView"
app:layout_constraintStart_toStartOf="@+id/textView"
app:layout_constraintTop_toBottomOf="@+id/textView" />
<TextView
android:id="@+id/textView3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:fontFamily="@font/roboto_medium"
android:text="Phone No"
android:textColor="#070707"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="@+id/textView2"
app:layout_constraintStart_toStartOf="@+id/textView2"
app:layout_constraintTop_toBottomOf="@+id/textView2" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
我的 MainActivity
public class DashboardActivity extends AppCompatActivity {
RecyclerView recyclerView;
RcvAdapter adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dashboard);
recyclerView = findViewById(R.id.recyclerView);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
// database = FirebaseDatabase.getInstance().getReference().child("Users");
// Retrive firebase data into recyclerview
FirebaseRecyclerOptions<ModelClass> options =
new FirebaseRecyclerOptions.Builder<ModelClass>()
.setQuery(FirebaseDatabase.getInstance().getReference().child("Users"), ModelClass.class)
.build();
adapter = new RcvAdapter(options);
recyclerView.setAdapter(adapter);
}
@Override
protected void onStart() {
super.onStart();
adapter.startListening();
}
@Override
protected void onStop() {
super.onStop();
adapter.stopListening();
}
模型类
public class ModelClass {
String address;
String bloodGroup;
String city;
String district;
String name;
String phoneNumber;
String contact;
public ModelClass() {
}
public ModelClass(String address, String bloodGroup, String city, String district, String name, String phoneNumber, String contact) {
this.address = address;
this.bloodGroup = bloodGroup;
this.city = city;
this.district = district;
this.name = name;
this.phoneNumber = phoneNumber;
this.contact = contact;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getBloodGroup() {
return bloodGroup;
}
public void setBloodGroup(String bloodGroup) {
this.bloodGroup = bloodGroup;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getDistrict() {
return district;
}
public void setDistrict(String district) {
this.district = district;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPhoneNumber() {
return phoneNumber;
}
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
public String getContact() {
return contact;
}
public void setContact(String contact) {
this.contact = contact;
}
}
血型数据和Phone没有填充。
DashboardActivity 布局
<androidx.constraintlayout.widget.ConstraintLayout 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:background="@color/dark_red"
tools:context=".DashboardActivity">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
由于您将默认 encoder/decoder 与 FirebaseRecycler class 一起使用,因此您应确保将数据库中的键名与模型中的键名相匹配。
例如,尝试将 ModelClass
中的“phoneNumber”更改为“phone”(与数据库相同)。