My Upload Code :
package com.example.mfapp;
public class Upload {
private String mName;
private String mImageUrl;
public Upload() {
}
public Upload(String name, String imageUrl) {
if (name.trim().equals("")) {
name = "No Name";
}
mName = name;
mImageUrl = imageUrl;
}
public String getName() {
return mName;
}
public void setName(String name) {
mName = name;
}
public void getImageUrl(String ImageUrl) {
mImageUrl = ImageUrl;
}
}
My ImageAdapter :
package com.example.mfapp;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.squareup.picasso.Picasso;
import java.util.List;
public class ImageAdapter extends RecyclerView.Adapter<ImageAdapter.ImageViewHolder> {
private Context mContext;
private List<Upload> mUploads;
public ImageAdapter(Context context,List<Upload> uploads){
mContext = context;
mUploads = uploads;
}
@NonNull
@Override
public ImageViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View v = LayoutInflater.from(mContext).inflate(R.layout.image_item,parent,false);
return new ImageViewHolder(v);
}
@Override
public void onBindViewHolder(@NonNull ImageViewHolder holder, int position) {
Upload uploadCurrent = mUploads.get(position);
holder.textViewName.setText(uploadCurrent.getName());
Picasso.with(mContext)
.load(uploadCurrent.getImageUrl()).fit().centerCrop().into(holder.imageView);
}
@Override
public int getItemCount() {
return mUploads.size();
}
public class ImageViewHolder extends RecyclerView.ViewHolder{
public TextView textViewName;
public ImageView imageView;
public ImageViewHolder(@NonNull View itemView) {
super(itemView);
textViewName = itemView.findViewById(R.id.text_view_name);
imageView = itemView.findViewById(R.id.image_view_upload);
}
}
}
Error in this string :
Picasso.with(mContext)
.load(uploadCurrent.getImageUrl()).fit().centerCrop().into(holder.imageView);
У меня ошибка в 39 строке. D:\MFAPP\app\src\main\java\com\example\mfapp\ImageAdapter.java:39: error: method getImageUrl in class Upload cannot be applied to given types; .load(uploadCurrent.getImageUrl()).fit().centerCrop().into(holder.imageView); ^ required: String found: no arguments reason: actual and formal argument lists differ in length