我想開發一個應用程序,其中回收站列表視圖從Firebase數據庫獲取數據,向用戶顯示詳細信息,如姓名,年齡,城市和個人資料圖片。如何從Firebase存儲中獲取圖片並顯示爲縮略圖?
如何從firebase存儲中獲取個人資料照片並在回收站列表視圖中顯示並顯示爲縮略圖。
@Override
public void onBindViewHolder(final UserViewHolder holder, final int position, Context context) {
this.context = context;
final BusinessDetailModel businessDetailModel = list.get(position);
Picasso.with(context).load(list.get(position).getImageUrl()).resize(80, 80).into(holder.thumbnail);
holder.businessName.setText(businessDetailModel.businessName);
holder.businessCity.setText(businessDetailModel.city);
holder.businessRating.setText(businessDetailModel.ratingValue + "");
解決方案,
您可以添加全局變量:
private Context context;
然後從這裏分配方面:
@Override
public FeedAdapter.ViewHolder onCreateViewHolder(ViewGroup parent,int viewType) {
View v=LayoutInflater.from(parent.getContext()).inflate(R.layout.feedholder, parent, false);
ViewHolder vh = new ViewHolder(v);
// set the Context here
context = parent.getContext();
return vh;
}
檢查我的代碼我更新我的問題,它是正確的嗎? –
是的,它似乎是正確的。 –
Nop,它顯示上下文不能爲空錯誤 –