gpt4 book ai didi

android - 字符串: Actual and formal argument lists differ in length中的错误

转载 作者:行者123 更新时间:2023-12-03 09:12:00 24 4
gpt4 key购买 nike

尝试在以下代码中实现setHeadline()时遇到“实际和形式参数列表的长度不同”错误。

private void setupAdaptater() {
mPostAdapter = new FirebaseRecyclerAdapter < Post, PostViewHolder > (
Post.class,
R.layout.item_layout_post,
PostViewHolder.class,
mPostRef
) {
@Override
protected void populateViewHolder(PostViewHolder viewHolder, final Post model, int position) {
StorageReference storageReference = FirebaseStorage.getInstance().getReferenceFromUrl(model.getImageUrl());
Glide.with(MainActivity.this)
.using(new FirebaseImageLoader())
.load(storageReference)
.into(viewHolder.postIV);
viewHolder.setHeadline(model.setHeadline()); //Headline
viewHolder.setNumLikes(model.getNumLikes());
viewHolder.postLikeIV.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
updateNumLikes(model.getUID());
}
});
}
};
}

//...
   public void setHeadline(String headline){ //Headline
postHeadline.setText(String.valueOf(headline)); //This string gives the value of headline_event
}

我定义这样的字符串:
public class Post {
private String headline; //Set headline as String;

public Post() {

}

public Post(String headline) {
this.headline = headline; //This is the headline that was added
}

public void setHeadline(String headline) { //Set the headline
this.headline = headline; //set the headline as string
}

//..

我不会弄到长度不匹配的地方。谁能帮我这个?

最佳答案

在您的Post类中,我看到以下代码:

public void getHeadline(String headline) { //Set the headline
this.headline = headline; //set the headline as string
}


您似乎在这里打了一个错字:方法是 g etHeadline,但它看起来像个“设置者”,因此应命名为 s etHeadline。

我希望看到两个看起来像这样的方法:
public String getHeadline() {
return headline;
}

public void setHeadling(String headline) {
this.headline = headline;
}

关于android - 字符串: Actual and formal argument lists differ in length中的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48176664/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com