Hello, I'm developing my CBT, and I do not know how to use a checkbox inside a BaseAdapter. My idea is, I have a window that shows me a list of requests and at the end of the list is the total, every item in that list has a checkbox, and I want to make when I click on a checkbox I bring the price of that item and I select more than one, add values, but I have no idea how to do this, I searched the internet, but I did not find anything.
Here is my baseAdapater:
public class FinalizarAdapter extends BaseAdapter {
private List<Auxiliar> pedido;
@SuppressWarnings("unused")
private Context context;
private LayoutInflater inflater;
public FinalizarAdapter(Context context, List<Auxiliar> pedido) {
this.pedido = pedido;
this.context = context;
this.inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return pedido.size();
}
@Override
public Object getItem(int arg0) {
// TODO Auto-generated method stub
return pedido.get(arg0);
}
@Override
public long getItemId(int arg0) {
// TODO Auto-generated method stub
return arg0;
}
@Override
public View getView(int position, View view, ViewGroup parent) {
ViewHolder holder = null;
if (view == null) {
holder = new ViewHolder();
int layout = R.layout.layout_inflater_finalizar_pedido;
view = inflater.inflate(layout, null);
view.setTag(holder);
holder.tvNome = (TextView) view.findViewById(R.id.tvLvItem);
holder.tvQtd = (TextView) view.findViewById(R.id.tvLvQtd);
holder.cbTotal = (CheckBox) view.findViewById(R.id.cbTotal);
} else {
holder = (ViewHolder) view.getTag();
}
Auxiliar pedi = pedido.get(position);
holder.tvNome.setText("" + pedi.getNome());
holder.tvQtd.setText("" + pedi.getQtd());
return view;
}
public class ViewHolder {
CheckBox cbTotal;
TextView tvNome;
TextView tvQtd;
}
}