Skip to content

Instantly share code, notes, and snippets.

@abbas-oveissi
Last active May 14, 2016 11:42
Show Gist options
  • Save abbas-oveissi/8d2f047cb5810252557c6ddd76a05238 to your computer and use it in GitHub Desktop.
Save abbas-oveissi/8d2f047cb5810252557c6ddd76a05238 to your computer and use it in GitHub Desktop.
package com.example.abbas.testssd;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.squareup.picasso.Picasso;
import java.util.List;
/**
* Created by Abbas on 14/05/2016.
*/
public class MyAdapter extends RecyclerView.Adapter<MyAdapter.View_Holder> {
List<Person> list = null;
Context context;
public MyAdapter(List<Person> list, Context context) {
this.list = list;
this.context = context;
}
@Override
public View_Holder onCreateViewHolder(ViewGroup parent, int viewType) {
//Inflate the layout, initialize the View Holder
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_layout, parent, false);
View_Holder holder = new View_Holder(v);
return holder;
}
@Override
public void onBindViewHolder(View_Holder holder, int position) {
Person mTemp=list.get(position);
holder.firstName.setText(mTemp.firstName);
holder.lastName.setText(mTemp.lastName);
Picasso.with(context).load(mTemp.profileImageUrl).into(holder.imgProfile);
}
@Override
public int getItemCount() {
return list.size();
}
public class View_Holder extends RecyclerView.ViewHolder {
TextView firstName,lastName;
ImageView imgProfile;
View_Holder(View itemView) {
super(itemView);
firstName = (TextView) itemView.findViewById(R.id.firstName);
lastName = (TextView) itemView.findViewById(R.id.lastName);
imgProfile = (ImageView) itemView.findViewById(R.id.imgProfile);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment