Here I am creating custom listview with checkbox / RadioButton. I got this but I need the single selection for that.
I try using this lstvw.setChoiceMode(ListV
You can use CheckBox in your adapter class. Try this.
@Override
public View getView(final int position, View convertView,
ViewGroup parent) {
// TODO Auto-generated method stub
if (convertView == null) {
inflater = LayoutInflater.from(adapterContext);
convertView = inflater.inflate(R.layout.view, null);
final ViewHolder viewHolder = new ViewHolder();
viewHolder.name = (TextView) convertView.findViewById(R.id.txtName);
viewHolder.checkBox = (CheckBox) convertView.findViewById(R.id.checkBox1);
convertView.setTag(viewHolder);
}
final ViewHolder holder = (ViewHolder) convertView.getTag();
holder.name.setText(collectContactList.get(position).getName());
holder.checkBox.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
CheckBox cb = (CheckBox) v;
if (cb.isChecked() == true)
{
// Here you will get list of checked item.
}
else
{
// Here you will get list of unchecked item.
}
}
});
Hope this will help you.