|
Quyidagi kodda, LinearLayout obyekti yaratiladi va ikkita Button qo'shiladi
|
bet | 3/3 | Sana | 20.05.2024 | Hajmi | 21,12 Kb. | | #245713 |
Bog'liq 1. Drawable ob’ektlari bilan ishlash (1)Quyidagi kodda, LinearLayout obyekti yaratiladi va ikkita Button qo'shiladi: java
• LinearLayout linearLayout = new LinearLayout(this);
• Button button1 = new Button(this);
• button1.setText("Birinchi tugma");
• Button button2 = new Button(this);
• button2.setText("Ikkinchi tugma");
• linearLayout.addView(button1);
• linearLayout.addView(button2);
• Bu kod LinearLayout va ikkita Button obyektlarini yaratadi va LinearLayout ga qo'shadi. • Quyidagi kodda, LinearLayout obyekti yaratiladi va Button qo'shiladi. Keyin, Button o'chiriladi: java
• LinearLayout linearLayout = new LinearLayout(this);
• Button button = new Button(this);
• button.setText("Bosing!");
• linearLayout.addView(button);
• linearLayout.removeView(button);
• Bu kod LinearLayout va Button obyektlarini yaratadi, Button ni LinearLayout ga qo'shadi va keyin removeView() metodi yordamida Button ni LinearLayout dan olib tashlaydi.
|
| |