Mavzu. Teskari zanjir usuli. Ishdan maqsad



Download 335,05 Kb.
bet2/3
Sana22.06.2022
Hajmi335,05 Kb.
#690205
1   2   3
public class MainActivity extends AppCompatActivity {

private EditText inputText;
private Button nateja;
private int sum;
private LinearLayout ijobiy;
private LinearLayout salbiy;

@Override


protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//get ids
salbiy = findViewById(R.id.salbiyNatijaId);
ijobiy = findViewById(R.id.ijobiyNatijaId);
inputText = findViewById(R.id.inputTextId);
nateja = findViewById(R.id.buttonId);

nateja.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {

sum = Integer.parseInt(inputText.getText().toString());

if (sum >= 10000000) {
ijobiy.setVisibility(View.VISIBLE);
salbiy.setVisibility(View.GONE);
} else if (sum < 1000000) {
salbiy.setVisibility(View.VISIBLE);
ijobiy.setVisibility(View.GONE);
} else {
Toast.makeText(MainActivity.this, "Ma'lumot yuq", Toast.LENGTH_SHORT).show();
}

}
});


}


}
XML ko’rinishi:
xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFEB0B"
android:orientation="vertical"
tools:context=".MainActivity"
>

<Space
android:layout_width="match_parent"
android:layout_height="16dp"
/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/dars_4"
android:textColor="#000"
android:textSize="24sp"
android:textStyle="bold"
/>

<Space
android:layout_width="match_parent"
android:layout_height="16dp"
/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/baliqchilik"
android:textColor="#FF5722"
android:textSize="24sp"
android:textStyle="italic"
/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:text="@string/hisobot"
android:textColor="#C4000000"
android:textSize="18sp"
android:textStyle="normal"
/>

<Space
android:layout_width="match_parent"
android:layout_height="8dp"
/>

<EditText
android:id="@+id/inputTextId"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:hint="@string/hisob"
android:inputType="numberDecimal"
android:padding="16dp"
android:textSize="18sp"
android:typeface="serif"
tools:ignore="Autofill"
/>

<Space
android:layout_width="match_parent"
android:layout_height="16dp"
/>

<Button
android:id="@+id/buttonId"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="30dp"
android:layout_marginEnd="30dp"
android:background="@drawable/buttonbackground"
android:padding="10dp"
android:text="@string/hisobotButton"
android:textColor="#FFEB3B"
android:textSize="20sp"
/>


<
Download 335,05 Kb.

Do'stlaringiz bilan baham:
1   2   3




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