Mavzu: Menyuni yaratish va undan foydalanish



Download 164,48 Kb.
Sana30.05.2022
Hajmi164,48 Kb.
#620078
Bog'liq
5-amaliy ish


O’ZBEKISTON RESPUBLIKASI AXBOROT TEXNOLOGIYALARI VA KOMMUNIKATSIYALARINI RIVOJLANTIRISH VAZIRLIGI
MUHAMMAD AL-XORAZMIY NOMIDAGI TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI

5-Amaliy ish


Mavzu: Menyuni yaratish va undan foydalanish
833-18 guruh Talabasi
Bajardi: Narzillayev Tursunpo’lat
Tekshirdi: Norkobilov S.A


Toshkent – 2022
5-amaliyot ishi

Menyuni yaratish va undan foydalanish

1. Ishdan maqsad



2. Topshiriq


  1. MetroPicker paketni modifikatsiyalash;

  2. Aktivlikda asosiy menyuni yaratish;

  3. TextView Taqdim etish uchun matnbop menyuni dinamik yaratish;

  4. Asosiy Aktivlik uchun asosiy menyuni yaratish.

package com.example.labaratoriya5;


import androidx.annotation.NonNull;


import androidx.appcompat.app.AppCompatActivity;

import android.annotation.SuppressLint;


import android.os.Bundle;
import android.view.ContextMenu;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.RadioButton;
import android.widget.TextView;
import android.widget.Toast;

import java.util.ArrayList;


public class MainActivity extends AppCompatActivity {


private ArrayList query;


private ArrayList ans_a, ans_b, ans_c, ans_true;
private TextView queryText;
private RadioButton a, b, c;
private int count = -1;
private boolean javob = false;

@Override


protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

queryText = findViewById(R.id.query);


a = findViewById(R.id.ans_a);
b = findViewById(R.id.ans_b);
c = findViewById(R.id.ans_c);

query = new ArrayList<>();


ans_a = new ArrayList<>();
ans_b = new ArrayList<>();
ans_c = new ArrayList<>();
ans_true = new ArrayList<>();

query.add("O'zbekiston Respublikasi mustaqilligi qachon e'lon qilingan?");


ans_a.add("1992 - yil 18 - noyabr");
ans_b.add("1991 - yil 31 - avgust");
ans_c.add("1991 - yil 1 - sentyabr");
ans_true.add("1991 - yil 31 - avgust");

query.add("O'zbekiston Respublikasi Davlat bayrog'i qachon qabul qilingan?");


ans_a.add("1991 - yil 18 - noyabr");
ans_b.add("1991 - yil 2 - iyun");
ans_c.add("1992 - yil 10 - dekabr");
ans_true.add("1991 - yil 18 - noyabr");

query.add("O'zbekiston Respublikasi konstitutsiyasi qachon qaul qilingan?");


ans_a.add("1992 - yil 8 - dekabr");
ans_b.add("1991 - yil 21 - oktyabr");
ans_c.add("1991 - yil 10 - dekabr");
ans_true.add("1992 - yil 8 - dekabr");

view_main(a, b, c, View.GONE);


}

@Override


public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main_menu, menu);
return true;
}

@Override


public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main_menu, menu);
menu.setHeaderTitle("Matnbop menyu");
}

private void view_main(RadioButton aa, RadioButton bb, RadioButton cc, int visible) {


aa.setVisibility(visible);
bb.setVisibility(visible);
cc.setVisibility(visible);
}

@SuppressLint("NonConstantResourceId")


@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
case R.id.item01:
queryText.setText(query.get(0));
a.setText(ans_a.get(0));
b.setText(ans_b.get(0));
c.setText(ans_c.get(0));
a.setChecked(false);
b.setChecked(false);
c.setChecked(false);
view_main(a, b, c, View.VISIBLE);
count = 0;
break;
case R.id.item02:
queryText.setText(query.get(1));
a.setText(ans_a.get(1));
b.setText(ans_b.get(1));
c.setText(ans_c.get(1));
a.setChecked(false);
b.setChecked(false);
c.setChecked(false);
view_main(a, b, c, View.VISIBLE);
count = 1;
break;
case R.id.item03:
queryText.setText(query.get(2));
a.setText(ans_a.get(2));
b.setText(ans_b.get(2));
c.setText(ans_c.get(2));
a.setChecked(false);
b.setChecked(false);
c.setChecked(false);
view_main(a, b, c, View.VISIBLE);
count = 2;
break;
// case R.id.item04:
// Toast.makeText(getApplicationContext(), "nimadir 4", Toast.LENGTH_LONG).show();
// break;
// case R.id.sub1item01:
// Toast.makeText(getApplicationContext(), "nimadir 5", Toast.LENGTH_LONG).show();
// break;
// case R.id.sub2item01:
// Toast.makeText(getApplicationContext(), "nimadir 6", Toast.LENGTH_LONG).show();
// break;
default:
break;
}

return super.onOptionsItemSelected(item);


}

@SuppressLint("NonConstantResourceId")


public void radioButton(View view) {
switch (view.getId()) {
case R.id.ans_a:
javob = ans_a.get(count).equals(ans_true.get(count));
break;
case R.id.ans_b:
javob = ans_b.get(count).equals(ans_true.get(count));
break;
case R.id.ans_c:
javob = ans_c.get(count).equals(ans_true.get(count));
break;
default:
break;
}
}

public void sendButton(View view) {


if (count != -1)
if (javob)
Toast.makeText(getApplicationContext(), "To'g'ri", Toast.LENGTH_SHORT).show();
else Toast.makeText(getApplicationContext(), "Noto'g'ri", Toast.LENGTH_SHORT).show();
}
}
dasturiy qism

xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">


android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="20dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" >


android:id="@+id/query"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Yakuniy test!"
android:textSize="20sp"
android:text
android:textColor="@color/black"/>


android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="20dp">


android:id="@+id/ans_a"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="A javob"
android:onClick="radioButton"/>


android:id="@+id/ans_b"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="B javob"
android:onClick="radioButton"/>


android:id="@+id/ans_c"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="C javob"
android:onClick="radioButton"/>






Download 164,48 Kb.

Do'stlaringiz bilan baham:




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