如何使用类型为自定义对象的 Eureka 构建 AlertRow

How to build an AlertRow with Eureka for which the type is a custom object

是否可以使用类型为自定义对象的 Eureka 库创建 AlertRow

例如,而不是:

<<< AlertRow<String>("categoryTag") {
        [=10=].title = "Category"
        [=10=].optionTitle = "Select a category"
        [=10=].options = ["Category 1", "Category 2"]
        [=10=].value = "Category 1"
    }

是否可以拥有:

<<< AlertRow<Category>("tag1") {
        [=11=].title = "AlertRow"
        [=11=].optionTitle = "Select Category"
        [=11=].options = [category1, category2]
        [=11=].value = category1
    }

类别是标准 class。

这样我就可以在 AlertRow 中显示类别名称并在选择类别时检索类别 ID。

可以用Eureka实现吗?

AlertRow 定义如下: public final class AlertRow<T: Equatable>: _AlertRow<T>, RowType 所以你可以用任何符合 Equatable.

的对象来定义它

此外 [=12=].displayValueFor 您可以自定义将显示为提醒行选项的文本。