[英]Found two getters or fields with conflicting case sensitivity for property: status
When i run my app it crashes and says it gets two getters of status.当我运行我的应用程序时,它崩溃并说它获得了两个状态获取者。 But in my code i have written Status not status.
但在我的代码中,我写的是状态而不是状态。 I don't know what is wrong please help me!
我不知道是什么问题,请帮助我! This is
Contacts.java
这是
Contacts.java
public class Contacts
{
public String name, Status, image;
public Contacts()
{
}
public Contacts(String name, String Status, String image)
{
this.name = name;
this.Status = Status;
this.image = image;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getStatus() {
return Status;
}
public void setStatus(String status) {
this. Status = status;
}
public String getImage() {
return image;
}
public void setImage(String image) {
this.image = image;
}
}
Here is FindFreindsActivity.java
这是
FindFreindsActivity.java
public class FindFreindsActivity extends AppCompatActivity {
private Toolbar mToolbar;
private RecyclerView FindfreindsRecyclerList;
private DatabaseReference UsersRef;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_find_freinds);
UsersRef = FirebaseDatabase.getInstance().getReference().child("Users");
FindfreindsRecyclerList = (RecyclerView) findViewById(R.id.find_freinds_recycler_list);
FindfreindsRecyclerList.setLayoutManager(new LinearLayoutManager(this));
mToolbar = (Toolbar) findViewById(R.id.find_freinds_toolbar);
setSupportActionBar(mToolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle("Find Freinds");
}
@Override
protected void onStart()
{
FirebaseRecyclerOptions<Contacts> options =
new FirebaseRecyclerOptions.Builder<Contacts>()
.setQuery(UsersRef, Contacts.class)
.build();
super.onStart();
FirebaseRecyclerAdapter<Contacts,FindFreindsViewHolder >adapter =
new FirebaseRecyclerAdapter<Contacts, FindFreindsViewHolder>(options) {
@Override
protected void onBindViewHolder(@NonNull FindFreindsViewHolder holder, final int position, @NonNull Contacts model) {
holder.userName.setText(model.getName());
holder.userStatus.setText(model.getStatus());
Picasso.get().load(model.getImage()).placeholder(R.drawable.profile_image).into(holder.profileImage);
}
@NonNull
@Override
public FindFreindsViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i)
{
View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.users_display_layout, viewGroup, false);
FindFreindsViewHolder viewHolder = new FindFreindsViewHolder(view);
return viewHolder;
}
};
FindfreindsRecyclerList.setAdapter(adapter);
adapter.startListening();
}
public static class FindFreindsViewHolder extends RecyclerView.ViewHolder
{
TextView userName, userStatus;
CircleImageView profileImage;
public FindFreindsViewHolder(@NonNull View itemView) {
super(itemView);
userName = itemView.findViewById(R.id.user_profile_name);
userStatus = itemView.findViewById(R.id.user_status);
profileImage = itemView.findViewById(R.id.users_profile_image);
}
}
}
In my firebase database status is written as Status and this activity is supposed to show all the people using this app, with their profile pic, username and their status.在我的 firebase 中,数据库状态被写为状态,这个活动应该显示所有使用这个应用程序的人,以及他们的个人资料图片、用户名和他们的状态。
Your Contacts object provides two ways to get a property called "status".您的联系人 object 提供了两种方法来获取名为“状态”的属性。
The first one is the fact that you've made Status
a public member:第一个是您已将
Status
公共成员:
public String name, Status, image;
The second is your accessor method:第二个是您的访问器方法:
public String getStatus() {
return Status;
}
The standard way to write POJO objects is to make your fields private and provide only public accessor methods.编写 POJO 对象的标准方法是使您的字段私有并仅提供公共访问器方法。
Do this instead:改为这样做:
private String name, Status, image;
Also consider making status
lowercase, as is the standard for Java object fields.还可以考虑将
status
设为小写,这是 Java object 字段的标准。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.