Last active
December 14, 2015 21:19
-
-
Save ricston-git/5150698 to your computer and use it in GitHub Desktop.
This file contains 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 View getView (int position, View convertView, ViewGroup parent) |
This file contains 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 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; | |
} | |
} |
This file contains 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
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; | |
} | |
} |
This file contains 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
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