在Android中使用getView和convertView

【在Android中使用getView和convertView】逆水行舟用力撑,一篙松劲退千寻。这篇文章主要讲述在Android中使用getView和convertView相关的知识,希望能为你提供帮助。
The right way (According to Google I/O-10) to use getView with the convertView-param within a custom adapter class.

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


    推荐阅读