package com.example.hodisalar;
import
bet 8/8 Sana 01.01.2022 Hajmi 1,84 Mb. #292188
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.Do'stlaringiz bilan baham: