Skip to content

Instantly share code, notes, and snippets.

@ricston-git
Last active December 14, 2015 21:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ricston-git/5150698 to your computer and use it in GitHub Desktop.
Save ricston-git/5150698 to your computer and use it in GitHub Desktop.
public View getView (int position, View convertView, ViewGroup parent)
public class Person {
private String name;
private String surname;
private Bitmap image;
public Person(String name, String surname) {
this.name = name;
this.surname = surname;
}
public String getName() {
return name;
}
public String getSurname() {
return surname;
}
public Bitmap getImage() {
return image;
}
public void setName(String name) {
this.name = name;
}
public void setSurname(String surname) {
this.surname = surname;
}
public void setImage(Bitmap image) {
this.image = image;
}
}
private class PersonsAdapter extends ArrayAdapter<Person> {
...
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.list_entry, null);
holder = new ViewHolder();
holder.nameTextView = (TextView) convertView.findViewById(R.id.person_name);
holder.surnameTextView = (TextView) convertView.findViewById(R.id.person_surname);
holder.personImageView = (ImageView) convertView.findViewById(R.id.person_image);
convertView.setTag(holder);
}
else {
holder = (ViewHolder) convertView.getTag();
}
Person person = getItem(position);
holder.nameTextView.setText(person.getName());
holder.surnameTextView.setText(person.getSurname());
//holder.personImageView.setImageBitmap(person.getImage());
return convertView;
}
}
static class ViewHolder {
private TextView nameTextView;
private TextView surnameTextView;
private ImageView personImageView;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment