如何在 Android Kotlin 中从 Json 模式和 Ui 模式创建表单
Posted
技术标签:
【中文标题】如何在 Android Kotlin 中从 Json 模式和 Ui 模式创建表单【英文标题】:How to create Form from Json schema and Ui schema in Android Kotlin 【发布时间】:2021-12-27 06:44:50 【问题描述】:?我是移动开发的新手,有点困惑如何在 Jetpack Compose 应用程序中执行此操作。我找到了很多在 React 中创建表单的方法。对于 android Kotlin 有 https://github.com/ellykits/neat-form ,但它需要不同的 Json 模式结构。我的 Json 架构如下:
"title": ".....",
"description": "",
"type": "object",
"required": [
"description",
"violationType"
],
"properties":
"videoLink":
"type": "string",
"title": "Видео",
"default": "https://....."
,
"description":
"type": "string",
"title": "....."
,
"violationType":
"type": "string",
"title": ".......?",
"enum": [
".....",
".....",
".....",
".....",
"....."
]
和 Ui 架构:
"description":
"ui:widget":"textarea"
,
"violationType":
"ui:widget":"radio"
,
"videoLink":
"ui:widget": "customVideoWidget"
,
"ui:order": [
"videoLink",
"description",
"violationType"
]
您能否建议我阅读哪些内容来了解如何使用 Json 模式创建表单?
非常感谢您的提前。
【问题讨论】:
【参考方案1】:我认为这可以通过创建一个 factory 类并传递表单项来完成,它会决定返回 FormItemView。
FormItemView 是扩展例如 MaterialTextInput 的视图,并设置从 json 获取的输入类型和占位符等。
【讨论】:
谢谢你的回答,我会努力的以上是关于如何在 Android Kotlin 中从 Json 模式和 Ui 模式创建表单的主要内容,如果未能解决你的问题,请参考以下文章
在 Android Studio Kotlin 中从 SQLite 数据库中删除数据
在 UBUNTU 中从 VS Code 运行 Kotlin 会产生 kotlinc:未找到