简体   繁体   English

发现两个 getter 或属性的区分大小写冲突的字段:状态

[英]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.

相关问题 com.google.firebase.database.DatabaseException:找到两个具有属性区分大小写的getter或字段 - com.google.firebase.database.DatabaseException: Found two getters or fields with conflicting case sensitivity for property: name 构建为发行版APK后出现错误,但调试APK则没有错误-错误:发现两个吸气剂或区分大小写的字段 - Error after building as release APK but no error with debug APK - Error: Found two getters or fields with conflicting case sensitivity 发现名称的冲突吸气剂:getText - found conflicting getters for name: getText java.lang.RuntimeException:在类 androidx.appcompat.widget.AppCompatImageView 上发现名称 isImportantForAccessibility 的 getter 冲突 - java.lang.RuntimeException: Found conflicting getters for name isImportantForAccessibility on class androidx.appcompat.widget.AppCompatImageView 尝试将消息上传到Firebase数据库时出现错误“发现冲突的吸气剂” - Getting an error “found conflicting getters” when trying to upload a message to a firebase database oop 中的属性可以是字段还是只是 setter 和 getter 方法的组合? - can property in oop be fields or is it just a combination of setters and getters methods? Java Locale区分大小写 - Java Locale case sensitivity jOOQ - DefaultRecordMapper - 区分大小写 - jOOQ - DefaultRecordMapper - Case sensitivity DbUnit:NoSuchColumnException和区分大小写 - DbUnit: NoSuchColumnException and case sensitivity MySQL区分大小写 - Case Sensitivity of MySQL
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM