I am working on a customized list view

here is my adapter class
public class MenubaseAdapter extends BaseAdapter {
private static ArrayList<MenuItem> searchMenuItemArraylist;
private LayoutInflater menuInflater;
public MenubaseAdapter( Context context,ArrayList<MenuItem> results) {
searchMenuItemArraylist=results;
menuInflater = LayoutInflater.from(context);
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return searchMenuItemArraylist.size();
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
iewHolder holder;
if(convertView==null)
{
convertView=menuInflater.inflate(R.layout.menu_list, null);
holder=new MenuViewHolder();
holder.txtItemName=(TextView)convertView.findViewById(R.id.textView_menuitem);
holder.txtItemPrice=(TextView)convertView.findViewById(R.id.textView_itemprice);
holder.txtItemQty=(TextView)convertView.findViewById(R.id.TextView_itemQty);
holder.selectChk=(CheckBox)convertView.findViewById(R.id.checkBox_menuchk);
convertView.setTag(holder);
}else {
holder=(MenuViewHolder)convertView.getTag();
}
holder.txtItemName.setText(searchMenuItemArraylist.get(position).getMenuItemname());
holder.txtItemPrice.setText(searchMenuItemArraylist.get(position).getMenuItemPrice());
holder.txtItemQty.setText(searchMenuItemArraylist.get(position).getItemQty());
holder.selectChk.setChecked(searchMenuItemArraylist.get(position).isSelected());
holder.selectChk.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
//how to select the listview item ?
}
});
return convertView;
}
static class MenuViewHolder
{
TextView txtItemName;
TextView txtItemPrice;
TextView txtItemQty;
CheckBox selectChk;
}
}
Now my problem is when I am clicking on the foodmenuitems the list get selected and the check box get checked.but if I only click on the checkbox then the list item won’t get selected.thnx in advance.
To keep the track of the selected items, take one temporary arraylist of your object or simple arraylist of string in which you will add or remove the selected items.
For example
You have one temporary arraylist
ArrayList<MenuItem> tempList;Now in getview method you will have to do two changes
notifyDatasetChangedmethod