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

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.

主站蜘蛛池模板: 江口县| 白城市| 山西省| 大埔县| 玉溪市| 洛川县| 越西县| 焦作市| 呼和浩特市| 樟树市| 南和县| 陆川县| 浏阳市| 太仆寺旗| 霍城县| 苏尼特左旗| 临泽县| 吉安县| 那曲县| 枣庄市| 怀柔区| 花垣县| 洛浦县| 江阴市| 高唐县| 长宁县| 区。| 沧州市| 青阳县| 资兴市| 临潭县| 长宁区| 广东省| 炉霍县| 宽城| 东乌珠穆沁旗| 望城县| 大田县| 彭阳县| 揭东县| 泸溪县|