1. Paket va importlar: Kod paket bayonoti va Android komponentlari va vositalari uchun zarur importlarni bilan boshlanadi.
2. Faoliyat sinfi: Ilovaning asosiy sinfi hisoblanadi `MainActivity`, `AppCompatActivity`dan meros olgan sinf hisoblanadi. Bu sinf ilovada barcha funksiyalarni bajarish uchun ishlatiladi.
3. Ko'rinishlar va o'zgaruvchilar: Kod faoliyatda ishlatiladigan ko'rinishlar va o'zgaruvchilarni e'lon qiladi. Bu holatda, so’zlar ro'yxatini ko'rsatish uchun `ListView`, shuningdek, insho matnlarini saqlash uchun TextView va boshqa o'zgaruvchilar mavjud.
4.Flipper bazasi adapteri: ‘AdapterFlipper_BaseAdapter’ Ilovaning bosh sahifasida mavjud bo`lgan joylarni CardView da namoyish etadi.
5. Flipper adapteri modeli: “AdapterFlipperModel’ sinfi ilovadagi rasmlar va ma’lumotlarni getterlar va setterlar orqali sinflarga ta’minlashda ishlatiladi.
6. Joylar haqida ma’lumot: ‘CityInformation’ sinfi ilovada biron bir joyni ko`rishga kirganda uning reytingi, aylanadigan joylari va masofalarini ko`rsatib beradi.
Umumiy holatda, "Ingliz tilini o’rganish ilovasi" mobil ilovalamizning mantiqiy tuzilishi ko'rinishlar, ma'lumotlar va funktsionalni ajratib turishga asoslanadi. Shaharlar, mashhur joylar, ular haqida ma’lumotlarni o`z ichiga oladigan dasturimizni pastda kodlarda va ekran tasvirlarida ko`rib chiqishimiz mumkin
“Sayohatni rejalashtirish ilovasi” mobil ilovasining ko’rinishi, ekran sur’atlari va tegishli dastur kodlari
Quyida Dasturning Bosh sahifasi tasviri. Biz bu yerda bir nechta CardView lardan foydalanganmiz har bir obyektda CardViewdan foydalanganmiz. Sahifada ScrollView tahrirlash usulidan foydalanganmiz.
1-rasm. Bosh sahifa.
CardView-dan foydalanuvchi interfeysida vizual ravishda ajratilgan maydon yaratish uchun foydalanish mumkin.
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="match_parent"
android:paddingBottom="20dp">
android:id="@+id/cardView5"
android:layout_width="102dp"
android:layout_height="102dp"
android:layout_marginTop="16dp"
app:cardBackgroundColor="#F44336"
app:cardCornerRadius="15dp"
app:cardElevation="15dp"
app:layout_constraintEnd_toEndOf="@+id/cardView4"
app:layout_constraintTop_toBottomOf="@+id/adapter_flipper_home">
android:layout_width="match_parent"
android:layout_height="match_parent">
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/lato_black"
android:text="All trips"
android:textColor="#FFFFFF"
android:textSize="18sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.512"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView5"
tools:ignore="DuplicateIds" />
android:id="@+id/imageView5"
android:layout_width="44dp"
android:layout_height="44dp"
android:layout_marginTop="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/baseline_list_alt_24" />
android:id="@+id/cardView2"
android:layout_width="102dp"
android:layout_height="102dp"
android:layout_marginTop="16dp"
app:cardBackgroundColor="#4CAF50"
app:cardCornerRadius="15dp"
app:cardElevation="15dp"
app:layout_constraintEnd_toStartOf="@+id/cardView5"
app:layout_constraintStart_toEndOf="@+id/cardView3"
app:layout_constraintTop_toBottomOf="@+id/adapter_flipper_home">
android:layout_width="match_parent"
android:layout_height="match_parent"
android:foregroundTint="#023A0F">
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/lato_black"
android:text="Hotel"
android:textColor="#FFFFFF"
android:textSize="18sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.517"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView4"
app:layout_constraintVertical_bias="0.65"
tools:ignore="DuplicateIds" />
android:id="@+id/imageView4"
android:layout_width="44dp"
android:layout_height="44dp"
android:layout_marginTop="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/baseline_hotel_24" />
Quyida dastur asosiy oynasining 2-bo`limi tasvirlangan. Biz bu yerda bir nechta CardViewlar joylashtirib ularni bir xil o`lchamda keltirishimiz uchun LinearLayout komponentasidan foydalanganmiz.
LinearLayout komponentasi - bu komponenta elementlarni chiziqli joylashtirish imkonini beradi
ImageView komponentasi – bu CardView yoki boshqa komponentalarga rasmlar joylashtirish maqsadida qo`llaniladi.
Do'stlaringiz bilan baham: |