Mavzu: Android Studio muhitini o‘rnatish. Vidjetlar bilan ishlash. Xodisalar o‘rnatish


package com.example.hodisalar; import



Download 1,84 Mb.
bet8/8
Sana01.01.2022
Hajmi1,84 Mb.
#292188
1   2   3   4   5   6   7   8
Bog'liq
Labaratoriya ishi 2 Mobil ilovalarini ishlab chiqish Xudoyberdiyev Asror

package com.example.hodisalar;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

EditText son1, son2;


TextView natija;
RadioGroup radioGroup;
RadioButton btn1, btn2,btn3, btn4;

@Override


protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
son1= findViewById(R.id.son1);
son2= findViewById(R.id.son2);
natija=findViewById(R.id.natija);
btn1=findViewById(R.id.btn1);
btn2=findViewById(R.id.btn2);
btn3=findViewById(R.id.btn3);
btn4=findViewById(R.id.btn4);


btn1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
son1.getText().toString();
son2.getText().toString();
double a1=Double.valueOf(son1.getText().toString());
double a2=Double.valueOf(son2.getText().toString());
double a3;
a3=a1+a2;
natija.setText(String.valueOf(a3));
}
});

btn2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
son1.getText().toString();
son2.getText().toString();
double a1=Double.valueOf(son1.getText().toString());
double a2=Double.valueOf(son2.getText().toString());
double a3;
a3=a1-a2;
natija.setText(String.valueOf(a3));
}
});

btn3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
son1.getText().toString();
son2.getText().toString();
double a1=Double.valueOf(son1.getText().toString());
double a2=Double.valueOf(son2.getText().toString());
double a3;
a3=a1*a2;
natija.setText(String.valueOf(a3));
}
});

btn4.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
son1.getText().toString();
son2.getText().toString();
double a1=Double.valueOf(son1.getText().toString());
double a2=Double.valueOf(son2.getText().toString());
double a3;
a3=a1/a2;
natija.setText(String.valueOf(a3));
}
});
}
}

Quydagi qisda elementlarni Id orqali tanlab olib ularni dasturga tanishtirdik.



Har bir arfimetik amal uchun alohida qilib buyruq yozdik.Buni bajarish jarayonida kelayotgan qiymatlarni Satr korinishidan son ko’rinishiga keltirib o’ttik va natijaga qaytarishda ham shundan foydalandik.

btn1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
son1.getText().toString();
son2.getText().toString();
double a1=Double.valueOf(son1.getText().toString());
double a2=Double.valueOf(son2.getText().toString());
double a3;
a3=a1+a2;
natija.setText(String.valueOf(a3));
}
});

btn2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
son1.getText().toString();
son2.getText().toString();
double a1=Double.valueOf(son1.getText().toString());
double a2=Double.valueOf(son2.getText().toString());
double a3;
a3=a1-a2;
natija.setText(String.valueOf(a3));
}
});


btn3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
son1.getText().toString();
son2.getText().toString();
double a1=Double.valueOf(son1.getText().toString());
double a2=Double.valueOf(son2.getText().toString());
double a3;
a3=a1*a2;
natija.setText(String.valueOf(a3));
}
});


btn4.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
son1.getText().toString();
son2.getText().toString();
double a1=Double.valueOf(son1.getText().toString());
double a2=Double.valueOf(son2.getText().toString());
double a3;
a3=a1/a2;
natija.setText(String.valueOf(a3));
}
});


Xulosa:

Men ushbu labaratoriya ishini bajarish mobaynida android studio dasturini o’rnatish va uning sozlamalari bilan tanishdim.Android Studio dasturda komponentalar bilan tanishdim va bu komponentalar yordamida sodda kalkulyator dasturini yaratdim.Ushbu komponentlarni hususiyatlari bilan tanishib chiqdim.
Download 1,84 Mb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6   7   8




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish