How to select multiple list items in horizontal listview. I want to select multiple items in a list and store these values in an array.
Async task to show sizelist
@Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
if (dialog != null) {
dialog.dismiss();
dialog = null;
}
if (flag == 1) {
sizeAdapter = new SizeAdapter(Product.this, arraysize, "fonts/GeosansLight.ttf");
list_size.setAdapter(sizeAdapter);
list_size.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Code to change selected item color in class HomeGS homeGS = arraysize.get(position);
if (homeGS.getSelected()) {
homeGS.setSizeProduct(homeGS.getSizeProduct());
homeGS.setSelected(false);
} else {
homeGS.setSizeProduct(homeGS.getSizeProduct());
homeGS.setSelected(true);
}
arraysize.set(position, homeGS);
sizeAdapter.notifyDataSetChanged();
size = arraysize.get(position).getSizeProduct();
}
});
} else if (flag == 0) {
}
}
}
This is my Size Adapter code to change background and text color of selected item.
if (oldData.get(position).getSelected()){
holder.txt_name.setText(oldData.get(position).getSizeProduct());
holder.txt_name.setBackgroundColor(Color.parseColor("#000000"));
holder.txt_name.setTextColor(Color.parseColor("#ffffff"));
}else {
holder.txt_name.setText(oldData.get(position).getSizeProduct());
holder.txt_name.setBackgroundResource(R.drawable.btn_border);
holder.txt_name.setTextColor(Color.parseColor("#000000"));
}
return convertView;
}