Return to Snippet

Revision: 48247
at June 27, 2011 17:22 by Raevonium


Initial Code
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = mInflater.inflate(R.layout.item, parent, false);
}
((TextView) convertView.findViewById(R.id.text)).setText(DATA[position]);
((ImageView) convertView.findViewById(R.id.icon)).setImageBitmap(
(position & 1) == 1 ? mIcon1 : mIcon2);
return convertView;
}

Initial URL
http://www.google.com/intl/sv-SE/events/io/2010/sessions/world-of-listview-android.html

Initial Description
The right way (According to Google I/O-10) to use getView with the convertView-param within a custom adapter class.

Initial Title
Using getView and convertView in Android

Initial Tags
android

Initial Language
Java