Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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