android room-如何将 set/println 转换为字符串?
发布时间:2022-09-09 07:42:12 413
相关标签: # java
我正在尝试将设置作为文本添加到电子邮件中
//Data class
@Entity(tableName = "inventory")
data class InventoryDataClass(
@PrimaryKey(autoGenerate = true)
var id: Int,
@NonNull var itemNumber: String,
@NonNull val itemDescription: String,
val currentInventory: Int?,
@NonNull val optimalInventory: Int,
@NonNull val minInventory: Int
)
// getting list from room
val inventoryList by mainViewModel.getInventoryItems.collectAsState(initial = emptyList())
//converting list to set
val emailNumber = inventoryList.map { item ->
println("Item Number: ${item.itemNumber} | Item Description: ${item.itemDescription} | Current Inventory: ${item.currentInventory.toString()}")}.toSet()
我能够得到我需要的输出:
I/System.out: Item Number: 123| Item Description: item1 | Current Inventory: 47
I/System.out: Item Number: 456| Item Description: item2 | Current Inventory: 8
...
如何将其作为字符串获取,并将其作为文本添加到电子邮件中?到目前为止,我只能找到科特林。单元
Log.d(TAG, "InventoryMainScreen: $emailNumber")
//output
D/MainActivity: InventoryMainScreen: [kotlin.Unit]
特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报