架构组件 返回到课程 Which of the following are reasons to use a ViewModel? 选择合适的多项回答。 A ViewModel and its data can survive orientation changes in an Activity/Fragment. A ViewModel allows you to separate code that updates the UI from code that doesn’t need to rely on the UI or its lifecycle. A ViewModel prevents your data from updating the UI automatically. A ViewModel is destroyed after which of the following ? always after onStop always after onDestroy after onDestroy, if it not a configuration change True or False: You should execute time-consuming tasks and I/O requests in your Activity/Fragment. True False Why should you initialize and store LiveData in your ViewModel instead of a UI Controller? Both the ViewModel and LiveData are lifecycle aware. To ensure that the LiveData isn’t destroyed when the UI Controller is destroyed. To hide or separate implementation details making your app more flexible. All of the above Which of the following allows you to use observe for changes? a LiveData object any mutable object any property in a ViewModel any property in a ViewModel or LiveData object True or False: It’s OK for a ViewModel to directly reference a View or LifecycleOwner class. True False 提交回答 error_outline 系统对测验进行评分时出现错误。请重试。