官术网_书友最值得收藏!

Using Android's UI coroutine dispatcher

With this done, we can now use the dispatcher in the same way we use any other, for example:

launch(dispatcher) {
val headlines = fetchRssHeadlines()
val newsCount = findViewById<TextView>(R.id.newsCount)
launch(UI) {
newsCount.text = "Found ${headlines.size} News"
}
}
The UI dispatcher comes from the library we just added, kotlinx-coroutines-android.

Executing the code at this point will work. The quantity of news will be correctly displayed on the application.

主站蜘蛛池模板: 堆龙德庆县| 花垣县| 大厂| 和龙市| 玉溪市| 临夏市| 滦平县| 新余市| 沁阳市| 陵川县| 南宁市| 始兴县| 青海省| 鄂伦春自治旗| 宁远县| 佛教| 甘德县| 桑日县| 阿尔山市| 永修县| 利辛县| 紫云| 革吉县| 怀化市| 易门县| 仙游县| 闵行区| 赣州市| 邢台市| 临夏县| 通河县| 泰安市| 象州县| 镇宁| 佛学| 松溪县| 轮台县| 丰顺县| 嘉祥县| 高邑县| 泌阳县|