2 zxd 72 zxd_72 于 2013.04.26 09:41 提问

如何修改动态列表的图像?

动态列表中包含一个 imageview 和一个 textview。我想在点击的时候改变指定位置的图像,如何实现?

public class CoverLetterAdaptor extends BaseAdapter
{
    String[] coverLetterItems;
    Context context;    
    private LayoutInflater mInflater;   
    int ht,wt;

public CoverLetterAdaptor(Context context,int ht,int 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;
}
}
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!