错误错误:找不到符号类毕加索

时间:2019-10-17 15:52:22

标签: java android gradle

使用最新版本的毕加索2.7 ...在毕加索中获取此错误,并使用正确的方法但仍无法解决,请帮忙

import com.squareup.picasso.Picasso;

import java.util.ArrayList;

public class UserRecyclerAdapter extends 
  RecyclerView.Adapter<UserRecyclerAdapter.UserViewHolder> {

  public interface OnItemClickListener
  {
      void onItemClick(int position);
  }

OnItemClickListener listener;
Context context;
ArrayList<Movie> list;


public UserRecyclerAdapter(Context context, ArrayList<Movie> list , OnItemClickListener listener) {
    this.context = context;
    this.list = list;
    this.listener=listener;
}

@Override
public UserRecyclerAdapter.UserViewHolder onCreateViewHolder( ViewGroup parent, int viewType) {

    LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View itemView = inflater.inflate(R.layout.single_row_layout,parent,false);
    UserViewHolder holder=new UserViewHolder(itemView);
    return holder;
}

@Override
public void onBindViewHolder(final UserRecyclerAdapter.UserViewHolder holder, int position) {

 Movie detail = list.get(position);

// holder.textview.setText(detail.getMovieName());


 holder.itemView.setOnClickListener(new View.OnClickListener() {
     @Override
     public void onClick(View v) {

         listener.onItemClick(holder.getAdapterPosition());
     }
 });
    Picasso.get().load("https://image.tmdb.org/t/p/w500"+detail.getPosterPath()).into(holder.imageview);

}

@Override
public int getItemCount()
{
    return list.size();
}

public class UserViewHolder extends RecyclerView.ViewHolder {

    View itemView;
   // TextView textview;
    ImageView imageview;

    public UserViewHolder(View itemView) {

        super(itemView);
       // textview = itemView.findViewById(R.id.textview);
        this.itemView = itemView;
        imageview = itemView.findViewById(R.id.imageview);
    }
  }
}

3 个答案:

答案 0 :(得分:0)

可能您没有在app.gradle文件中添加依赖项,

 implementation 'com.squareup.picasso:picasso:2.71828'

请检查。如果已经添加,请尝试使用File->与Gradle文件同步项目。

希望它会起作用。

答案 1 :(得分:0)

尝试使缓存无效/重新启动... 获取文件/使缓存无效/重新启动...>

答案 2 :(得分:0)

确保您的课程在package文件夹中,并确保您在课程顶部具有正确的package语句。