Toshkent axborot texnologiyalari universiteti samaroand filiali


Activity.runOnUiThread (Runnable)


Download 39.75 Kb.
bet4/4
Sana17.06.2023
Hajmi39.75 Kb.
#1539658
1   2   3   4
Bog'liq
thereds

Activity.runOnUiThread (Runnable)

  • View.post (Runnable)

  • View.postDelayed Runnable, long)

    Masalan, View.post (Runnable) dan foydalanib, boshqa Thread ichidagi UI Thread-ga (masalan, ExampleThread) quyidagi ko’rinishda kirishingiz mumkin:
    4-kod rasmiga ozgina o’zgartirish qildik va xato yo’q.
    Thread bo’yicha umumiy misol
    Asinxron jarayonni tushunish uchun kelilar bitta misol qilamiz.
    activity_main.xml
    MainActivity.java
    MainActivity ichida DOWNLOAD IMAGE tugmachasini bosish orqali downloadImage() metodini chaqiradi. Ushbu metod DownloadImage yangi threadni boshlaydi.
    DownloadImage Threadi rasmni tarmoq orqali yuklab oladi va uni ImageView-da ko’rsatadi va keyin Image Downloaded tushdi xabarini ko’rsatadi.
    Eslatma: AndroidManifest faylini oching va tarmoq orqali rasm yuklab olish uchun INTERNET ruxsatini qo’shing.

    Threadexample android dasturini ishga tushirishda quyidagi ko’rinishga ega bo’ladi:

    manbaa : medium.com


    muallif : Aziz Ismoilov

    Download 39.75 Kb.

    Do'stlaringiz bilan baham:
  • 1   2   3   4




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