ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 70 - Associate Android Developer discussion

Report
Export

As an example. In an Activity we have our TimerViewModel object (extended ViewModel), named mTimerViewModel. mTimerViewModel.getTimer() method returns a LiveData<Long> value. What can be a correct way to set an observer to change UI in case if data was changed?

A.
mTimerViewModel.getTimer().getValue().toString().observe(new Observer<Long>() { @Overridepublic void onChanged(Long aLong) { callAnyChangeUIMethodHere(aLong)}});
Answers
A.
mTimerViewModel.getTimer().getValue().toString().observe(new Observer<Long>() { @Overridepublic void onChanged(Long aLong) { callAnyChangeUIMethodHere(aLong)}});
B.
mTimerViewModel.getTimer().observe(this, new Observer<Long>() { @Overridepublic void onChanged(Long aLong) { callAnyChangeUIMethodHere(aLong)}});
Answers
B.
mTimerViewModel.getTimer().observe(this, new Observer<Long>() { @Overridepublic void onChanged(Long aLong) { callAnyChangeUIMethodHere(aLong)}});
C.
mTimerViewModel.observe(new Observer<Long>() { @Overridepublic void onChanged(Long aLong) { callAnyChangeUIMethodHere(aLong)}});
Answers
C.
mTimerViewModel.observe(new Observer<Long>() { @Overridepublic void onChanged(Long aLong) { callAnyChangeUIMethodHere(aLong)}});
Suggested answer: B
asked 18/09/2024
Alajauan Adams
35 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first