gpt4 book ai didi

android - 无法从 Single> 获取第一项

转载 作者:行者123 更新时间:2023-11-29 18:25:22 25 4
gpt4 key购买 nike

在一个android项目中,我有这样的语句:

import io.reactivex.Completable
import io.reactivex.Single

val itemsList: Single<List<T>> = getItems()

我需要从 itemsList 中获取第一项。

我该怎么做?

最佳答案

作为您的 Single类型为 List<Item> , 什么时候你会在你的 apiRepositoryObject 上获取它- 您的网络层对象,您将获得单个 List<Item>或异常

apiRepositoryObject.getItems()
.subscribe(listOfItems -> {
// The list of item should be handled here
},Throwable::printStackTrace);

关于android - 无法从 Single<List<T>> 获取第一项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59323683/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com