I want to make a view where I can select multiple items from listview and also side by side am changing the color of selected list item and saving that item into my arraylis
Whatever you try to do with ConvertView in itemClick listener it will reflect in some other class, to avoid that you need to set the background for corresponding view holder , i show up some sample which works fine for me,
public View getView(final int position, View convertView, ViewGroup parent) {
System.gc();
final ViewHolder holder;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.albumlist, null);
holder = new ViewHolder();
holder.albumName = (TextView) convertView.findViewById(R.id.albumDetails);
convertView.setTag(holder);
}
else {
holder = (ViewHolder) convertView.getTag();
}
holder.albumName.setText(albumData[position][0]);
holder.albumName.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
holder.albumName.setBackgroundColor(R.color.black);
}});
return convertView;
}
class ViewHolder {
TextView albumName;
}
sample o/p