Picasso无法在recyclerview上的CircleImageView上设置图像

时间:2018-05-06 05:24:18

标签: android android-recyclerview picasso

我试图将firebase中的数据加载到我的回收站视图中。我首先检索的两个值是Name,第二个是ImageUrl。当我运行我的应用程序时,名称中的值显示在recyclerview上,但图像仍为空白。不知何故,毕加索未能将图像加载到CircleImageView中。

以下是我的ViewHolderclass

public static class CategoryViewHolder extends RecyclerView.ViewHolder {

View mView;
CircleImageView categoryImageView;
TextView categoryName;

public CategoryViewHolder(View itemView) {
    super(itemView);

    mView = itemView;

}

public void setDisplayName(String name){

     categoryName = (TextView) mView.findViewById(R.id.Category_name);
    categoryName.setText(name);

}


public void setUserImage(String thumb_image, Context ctx){

    categoryImageView = (CircleImageView) 
mView.findViewById(R.id.Category_pic);



 Picasso.with(ctx).load(thumb_image).placeholder(R.drawable. 
   default_avatar)
 .into( categoryImageView);
 //   Picasso.with(ctx) .load(thumb_image)  .into(categoryImageView);
}


 }

这是我的模特课

public class CategoryItems {
private  String Name;
private String ImageUrl;

public CategoryItems(String title, String imageURL) {
this.Name = title;
this.ImageUrl = imageURL;
}


publ  ic CategoryItems(){

                   }

public String getName() {
return Name;
}

 public void setName(String name) {
Name = name;
}

public String getImageUrl() {
return ImageUrl;
}

 public void setImageUrl(String imageUrl) {
ImageUrl = imageUrl;
}
}

这是我的FirebaseREcyclerViewAdapter

public void onStart() {
super.onStart();
startListening();
}

 public void startListening(){
  Query query = FirebaseDatabase.getInstance()
        .getReference()
        .child("Catlist")
        .limitToLast(500);

    FirebaseRecyclerOptions<CategoryItems> options =
        new FirebaseRecyclerOptions.Builder<CategoryItems>()
                .setQuery(query, CategoryItems.class)
                .build();
   FirebaseRecyclerAdapter adapter = new 
   FirebaseRecyclerAdapter<CategoryItems, CategoryViewHolder>(options) {
    @Override
    public CategoryViewHolder onCreateViewHolder(ViewGroup parent, int 
  viewType) {


        View view = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.category_items, parent, false);



        return new CategoryViewHolder(view);
    }

    @Override
    protected void onBindViewHolder(final CategoryViewHolder holder, int 
   position, final CategoryItems model) {

        holder.setDisplayName(model.getName());
        holder.setUserImage(model.getImageUrl(), getContext());
     //   holder.setUserStatus(model.getStatus());
        Log.d(model.getImageUrl().toString(), "onBindViewHolder: ");


    }
};
mUsersList.setAdapter(adapter);
adapter.startListening();
}

我的回收商只显示名称,我试图记录图像并显示网址

1 个答案:

答案 0 :(得分:0)

尝试启用Picasso中的登录以查看错误和警告,它肯定会在您的案例中显示一些错误,您可以解决。

int days = totalSeconds / 86400;
totalSeconds -= days * 86400;
int hours = totalSeconds / 3600;
totalSeconds -= hours * 3600;
int minutes = totalSeconds / 60;
int seconds = totalSeconds % 60;

有关详细信息,请查看此link