hi everyone,i have managed to add button dynamically in android studio,
my question is i wont to declare that button public so that i can be able to access it
below is my code
- for (int i=1;i<=5; i++)
- {
- final Button btn= new Button(this);
- btn.setLayoutParams(new LinearLayout.LayoutParams(250,250));
- btn.setId(i);
- btn.setText("DATABASE" +i);
- btn.setText(itemArrayList.get(i).getCategory_desc()+"");
- layout.addView(btn);
- }
i cant acces that button outside that for loop
any assistance will be appreciated