Saving Data on Android



Download 19,28 Mb.
Pdf ko'rish
bet177/292
Sana24.01.2022
Hajmi19,28 Mb.
#407089
1   ...   173   174   175   176   177   178   179   180   ...   292
Bog'liq
Bailey J., Dominguez A., Djermanovic D. - Saving Data on Android (1st Edition) - 2019

ResultActivity.kt
 file under the 
view
 package. Add the following code 
inside 
onCreate()
, importing the 
scoreTextView
 from 
activity_result
 XML:
val
 score = intent.extras?.getInt(QuestionActivity.SCORE) 
val
 numberOfQuestions = 
intent.extras?.getInt(QuestionActivity.NUMBER_OF_QUESTIONS) 
scoreTextView.text = 
String.format(getString(R.string.score_message), score, 
numberOfQuestions)
Saving Data on Android Chapter 9: Using Room with Google's Architecture Components
raywenderlich.com
166


That's it! 
build and run
 your app to see it in action:
Now, try clicking the 
START
 button and you should see the empty screen layout:
Saving Data on Android Chapter 9: Using Room with Google's Architecture Components
raywenderlich.com
167


Now, go back to the main screen and click the 
prepopulate
 button in your action 
bar:
Click 
START
 and you should now see your question and answers displayed:
Saving Data on Android Chapter 9: Using Room with Google's Architecture Components
raywenderlich.com
168


Answer the questions and take a look at the final screen to see your score!
Sweet! Your app is now working and displaying your Question and Answers!
Key points

LiveData
 is a data holder class, like a 
List
, that can be observed for changes by an 
Observer
.

LiveData
 is lifecycle-aware, meaning it can observe the lifecycle of Android 
components like the 
Activity
 or 
Fragment
. It will only keep updating observers if 
its component is still active.
• The 
ViewModel
 is part of the 

Download 19,28 Mb.

Do'stlaringiz bilan baham:
1   ...   173   174   175   176   177   178   179   180   ...   292




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