Android Open Source - SampleAndroidL Image Adapter

From Project

Back to project page SampleAndroidL.


The source code is released under:

GNU General Public License

If you think the Android project SampleAndroidL listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*from w w  w  .ja va  2s . c  o  m*/
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.List;


 * Created by Fabio Ranieri on 20/10/14.
 * Copyright 2014 Fingerlinks s.r.l.
public class ImageAdapter extends RecyclerView.Adapter<ImageAdapter.ViewHolder> {

    private List<Image> images;
    private int rowLayout;
    private Context mContext;

    public ImageAdapter(List<Image> images, int rowLayout, Context context) {
        this.images = images;
        this.rowLayout = rowLayout;
        this.mContext = context;

    public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
        final View v = LayoutInflater.from(viewGroup.getContext()).inflate(rowLayout, viewGroup, false);
        return new ViewHolder(v);

    public void onBindViewHolder(ViewHolder viewHolder, final int i) {
        Image _bean = images.get(i);;
                mContext.getDrawable(CodeUtils.getImageResourceId(mContext, _bean.imageName)));

    public int getItemCount() {
        return images == null ? 0 : images.size();

    public class ViewHolder extends RecyclerView.ViewHolder {
        public TextView name;
        public ImageView image_url;

        public ViewHolder(View itemView) {
            name = (TextView) itemView.findViewById(;
            image_url = (ImageView)itemView.findViewById(;


Java Source Code List