0
Hello, I’m developing my TCC, and I don’t know how to use checkbox inside a baseAdapter. My idea is, I have a window that shows me a list of orders and at the bottom of the list this total, each item on that list has a checkbox, and I want to make sure that when I click on a checkbox I bring the price of that item and if I select more than one, add the values, however I have no idea how to do this, I searched the internet, but found nothing.
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;
}
}