I have made some buttons and stored them into an ArrayList. I need to add these buttons to my main activity layout.
I have tried to create a linearlayout and make that my main layout, however the buttons do not show.
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// createButtons();setContentView(new CircleView(this));
}
public void createButtons() {
ArrayList<Button> buttons = new ArrayList<>();
int n = 0; // the number of buttons circumferencing the semicircle
for(int i = 0; i < 6; i ++) {
n = 7;
Button button = new Button(this);
double Xval = 500* Math.cos(i * Math.PI / n);
double Yval = 500* Math.sin(i * Math.PI / n);
button.setX((float)(Xval));
button.setY((float)(Yval));
buttons.add(button);
}
}
}
I expect to have my buttons appear in my main activity layout.