私はアダプタに画像をロードするためにフレスコライブラリを使用しました。しかし、私が期待したように画像が正しく設定されていません。これが私のコードです。私を助けてください。前もって感謝します。
public class HomeListingAdapter_recyler1 extends RecyclerView.Adapter {
プライベート コンテキスト コンテキスト。
プライベート ArrayList propertyItemList;
プライベート ImageLoader mImageLoader;
public HomeListingAdapter_recycler1(HomeListingActivity_recycler propertyViews, ArrayList propertyItemList) {
Fresco.initialize(propertyViews);
this.propertyItemList = propertyItemList;
this.context = propertyViews;
}
@オーバーライド
public CustomViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
itemLayoutView = LayoutInflater.from(parent.getContext()).inflate(R.layout.property_item_layout,parent,false); を表示します。
CustomViewHolder viewHolder = new CustomViewHolder(itemLayoutView);
ビューホルダーを返します。
}
@オーバーライド
public void onBindViewHolder(最終的な CustomViewHolder ホルダー、最終的な int 位置) {
mImageLoader = VolleySingletonPattern.getInstance(context).getImageLoader();
holder.txtPropertyName.setText(propertyItemList.get(position).ville);
holder.txtPropertyType.setText(propertyItemList.get(position).bienName);
if(propertyItemList.get(position).pieces.equalsIgnoreCase("0")){
holder.txtPropertySurfaceArea.setText(propertyItemList.get(position).surface+" "+context.getString(R.string.meter_square));
}else{ holder.txtPropertySurfaceArea.setText(propertyItemList.get(position).surface+" "+context.getString(R.string.meter_square)+" - "+ propertyItemList.get(position).pieces+" "+context.getResources( .getString(R.string.pieces));
}
holder.txtPropertyPrice.setText(propertyItemList.get(position).montantLoyer);
ウリ imageUri;
試す {
if(!TextUtils.isNullOrEmpty(propertyItemList.get(position).photo)) {
imageUri = Uri.parse(propertyItemList.get(position).photo);
holder.imgPropertyImage.setVisibility(View.VISIBLE);
holder.imgPropertyImage.setImageURI(imageUri);
}
キャッチ(例外e){
}
}
@オーバーライド
public int getItemCount() {
return propertyItemList.size();
}
public class CustomViewHolder extends RecyclerView.ViewHolder {
SimpleDraweeView imgPropertyImage;
public TextView txtPropertyName、txtPropertyType、txtPropertySurfaceArea、txtPropertyPrice;
public CustomViewHolder(View itemView) {
スーパー (itemView);
imgPropertyImage = (SimpleDraweeView) itemView.findViewById(R.id.image_property);
txtPropertyName = (TextView) itemView.findViewById(R.id.txt_property_name);
txtPropertyType = (TextView) itemView.findViewById(R.id.txt_property_type);
txtPropertySurfaceArea = (TextView) itemView.findViewById(R.id.txt_property_surface_piece);
txtPropertyPrice = (TextView) itemView.findViewById(R.id.txt_property_price);
}
}
}