问题描述
- 如何修改动态列表的图像?
- 动态列表中包含一个 imageview 和一个 textview。我想在点击的时候改变指定位置的图像,如何实现?
public class CoverLetterAdaptor extends BaseAdapter{ String[] coverLetterItems; Context context; private LayoutInflater mInflater; int htwt;public CoverLetterAdaptor(Context contextint htint wt String[] coverLetterTitle){ this.context = context; this.coverLetterItems = coverLetterTitle ; this.ht = ht; this.wt = wt; mInflater = LayoutInflater.from(context);}public int getCount() { return coverLetterItems.length;}public Object getItem(int position) { return position;}public long getItemId(int position) { return position;}public View getView( final int position View convertView ViewGroup parent) { ViewHolder holder; if (convertView == null) { convertView = mInflater.inflate(R.layout.coverletteradaptor null); holder = new ViewHolder(); holder.coverLetterTxt = (TextView) convertView.findViewById(R.id.coverLetterAdaptorTxt); holder.bgImageCCAdaptor = (ImageView)convertView.findViewById(R.id.bgimageCoverLetter); holder.bgimageCoverLetter = (ImageView)convertView.findViewById(R.id.bgimageCoverLetterr); holder.bgimageCoverLetter.setLayoutParams(new RelativeLayout.LayoutParams(wt ht/7)); convertView.setTag(holder); } else holder = (ViewHolder) convertView.getTag(); holder.coverLetterTxt.setText(coverLetterItems[position]); return convertView;} static class ViewHolder{ TextView coverLetterTxt; ImageView bgImageCCAdaptor; ImageView bgimageCoverLetter;}}
时间: 2024-12-31 13:09:20