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

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.

主站蜘蛛池模板: 武宁县| 延川县| 文山县| 平凉市| 海兴县| 扎兰屯市| 连城县| 夏津县| 广宁县| 湖南省| 象山县| 新绛县| 河南省| 策勒县| 清远市| 江永县| 交城县| 景德镇市| 平陆县| 华安县| 福泉市| 千阳县| 河曲县| 上饶县| 丹棱县| 辛集市| 石台县| 宜宾县| 安宁市| 敖汉旗| 苍南县| 大兴区| 台山市| 鄢陵县| 灵山县| 南丰县| 扶风县| 深州市| 元氏县| 吕梁市| 张家港市|