I have dynamic listview which contain 1 imageview and 1 textview.
My problem is I have to change the image of particular position in onclick
Here is my code
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;
}
}
Pls help me
Thanks
You can implement an OnItemclicklistener and then react to Itemclicks. Use this method to change the source of the bitmap then.
It works now with the above method. here is the code.