Every time i press a button i fill a GridLayout with several buttons. This is the code that do it, but i don't think it's necessary for you to understand my problem
for(int i=0; i < numeroBottoni;i++){
Spec row = GridLayout.spec(numeroRiga, 1);
Spec colspan = GridLayout.spec(numeroColonna, 1);
GridLayout.LayoutParams gridLayoutParam = new GridLayout.LayoutParams(row,colspan);
gridLayoutParam.width=larghezzaColonna;
gridLayoutParam.height=larghezzaColonna;// l'altezza della colonna la faccio uguale alla larghezza
gridLayout.addView(buttonName,gridLayoutParam);
}
The new buttons overlap the old ones, so i suppose i should "delete" the old buttons before adding the new ones.
But i dont know what i should do. I don't know if i have to "delete" the button or if i have to "clean" the GridLayout.
I tried to call invalidate() both on button and GridLayout but this is not the solution
Try this code
gridLayout.removeAllViews();
before adding the new views. Before your for loop in your code
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With