java - Overlapping buttons in android -


In Android, I am trying to add the button to programmatically, but all the buttons added are overlapping that code I'm using this to a certain extent:

 for  (int i = (int) 'a'; i & lt; = (int) 'z'; i + +) {Button button = new button (this); Four characters = (four) I; String letter on button = character.Tratring (letter); Button.setText (letterOnButton); Find Relative Layout RL = (Relative Layout) VVBIID (RIDDinBotone); Layout: LP = New Layout Prurm (Layout Perm. WRAP_CONTENT, Layout Para. WRAP_CONTENT); Rl.addView (button, LP); }  

This does not thrust a button, but I only see the "z" button.

Any ideas about fixing it?

As mentioned above, the linear layout will be the best solution, but if you still have a relay layout If you want to use, try setting each button ID, and the next parameter RIGHT_OF / BELOW .. This parameter "layout_alignLeft" will produce the same parameter, which means increasing all buttons in one position

< Pre> Find RELIOUT layout RL = (relative layout) VVIBID (RID layout); Int id = 0; For (int i = (int) 'a'; i & lt; = (int) 'z'; i ++) {button button = new button (this); Four characters = (four) I; String letter on button = character.Tratring (letter); Button.setText (letterOnButton); Button.setId (i); Layout: LP = New Layout Prurm (Layout Perm. WRAP_CONTENT, Layout Para. WRAP_CONTENT); Lp.addRule (relative layout. Belo, ID); Rl.addView (button, LP); Id = i; }

Comments