Guest User

Untitled

a guest
Dec 16th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. Button button1 = new Button(this);
  2.  
  3. for (int x = 1; x <= 4; x++) {
  4.  
  5. Button button1 = new Button(this);
  6. }// something like this
  7.  
  8. LinearLayout layout = findViewById(R.id.yourlayout);
  9.  
  10. List<Button> list = new ArrayList<>();
  11.  
  12. for (int x = 1; x <= 4; x++) {
  13. Button button = new Button(this);
  14.  
  15. button.setOnClickListener(new View.OnClickListener() {
  16. @Override
  17. public void onClick(View v) {
  18. // code
  19. }
  20. });
  21.  
  22. list.add(button);
  23. layout.addView(button);
  24. }
Add Comment
Please, Sign In to add comment