Created
October 6, 2017 10:37
-
-
Save BallerIndustries/c8f90c081b0bf5ca72edd79a4cbf7c1a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ImageAdapater extends RecyclerView.Adapter<ImageAdapater.ViewHolder> { | |
private Context mContext; | |
private List<Photo> mData; | |
public ImageAdapater(Context context, List<Photo> data) { | |
this.mContext = context; | |
this.mData = data; | |
} | |
@Override | |
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { | |
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.cell_photo, parent, false); | |
return new ViewHolder(view); | |
} | |
@Override | |
public void onBindViewHolder(ViewHolder holder, int position) { | |
Photo photo = mData.get(position); | |
Picasso.with(mContext).load(photo.url_l).into(holder.mImageView); | |
} | |
@Override | |
public int getItemCount() { | |
return mData.size(); | |
} | |
public class ViewHolder extends RecyclerView.ViewHolder | |
{ | |
public ImageView mImageView; | |
public ViewHolder(View itemView) { | |
super(itemView); | |
mImageView = (ImageView)itemView.findViewById(R.id.photo); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment