11-Ma’ruza Mavzu: Resurslar va fragmentlar. Reja: Resurslar bilan ishlash


Download 345.81 Kb.
bet12/12
Sana23.06.2023
Hajmi345.81 Kb.
#1652619
1   ...   4   5   6   7   8   9   10   11   12
Bog'liq
11-maruza

onViewCreated() usuli bajarilganda, ko'rinish allaqachon yaratilgan va u birinchi parametr - View obyekti sifatida uzatiladi, bu orqali identifikatorlar yordamida biz Visual elementlarni - TextView va Button olishimiz mumkin. ko'rinish.
Qolgan umr tsikli usullari uchun oddiy jurnallar Log.d() usuli yordamida o'rnatiladi.
activity_main.xml fayliga fragment qo'shamiz:


xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fragment_container_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.example.fragmentapp.ContentFragment" />

Va MainActivity klassi:


package com.example.fragmentapp;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}

Agar biz loyihani ishga tushirsak, u holda qurilma ekranida biz fragment uchun aniqlangan vizual interfeysni ko'ramiz.



Va Android Studio dagi Logcat oynasida siz hayot aylanishi usullarini hisobga olishni kuzatishingiz mumkin.

Download 345.81 Kb.

Do'stlaringiz bilan baham:
1   ...   4   5   6   7   8   9   10   11   12




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