Quyidagi kodda, LinearLayout obyekti yaratiladi va ikkita Button qo'shiladi




Download 21,12 Kb.
bet3/3
Sana20.05.2024
Hajmi21,12 Kb.
#245713
1   2   3
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.
Download 21,12 Kb.
1   2   3




Download 21,12 Kb.

Bosh sahifa
Aloqalar

    Bosh sahifa



Quyidagi kodda, LinearLayout obyekti yaratiladi va ikkita Button qo'shiladi

Download 21,12 Kb.