I need to go through a grid that I create in a dynamic way when adding an order. But when I delete an order the way I ask if this check is through a cycle of the number of children plus the tag I gave when creating it.
CheckBox cb = new CheckBox(view.getContext());
cb.setHeight(120);
cb.setBackgroundResource(R.drawable.back_button);
cb.setTag("cb" + i);
cb.setText(cb.getTag().toString());
To ask if this check I do the following and remove the view created by its LinearLayout tag
for(int i = 0; i < linear.getchildcount; i++)
{
CheckBox cb = linearLayout.findViewWithTag("cb"+i);
if(cb.isSelected())
{
// ELIMINO LA COLUMNA SELECCIONADA //
linearLayout.removeView(linearLayout.findViewWithTag("ly" + i));
}
else
{
Toast.makeText(getApplicationContext(),"No Esta Check.",Toast.LENGTH_SHORT).show();
}
If I generate 3 Checkbox
1 cb1
2 cb2
3 cb3
And I eliminate item 2
1 cb1
3 cb3
Going back to tour gives me an error because there is no 2. try to change the tag after deleting the remaining children but I get an error.
Thank you very much in advance.