【发布时间】:2018-07-02 19:18:30
【问题描述】:
因此,我在 Firestore 数据库中的一个文档中有一个简单的数值,我正在尝试获取该数值。到目前为止,我只为字符串对象和自定义对象做过:
String wkCategory = task.getResult().getString("setting");
所以我认为数字应该是一样的。我知道它只能获得 Long 或 Doubles,所以我尝试了这个:
int time = task.getResult().getLong("duration").intValue();
还有这个:
Number time = task.getResult().getLong("duration").intValue();
然后我将包中的值传递给下一个片段,它在 TextView 中设置。
private int time;
Bundle bundle =getArguments();
if(null!=bundle) {
time=bundle.getInt("Time");
}
TextView time = (TextView) view.findViewById(R.id.time);
time.setText(time.toString());
但是,这就是我的 TextView 中显示的内容。正如我所说,它可以正常使用字符串。虽然无法弄清楚,因为我什至使用了
.toString OR +""
【问题讨论】:
标签: android database google-cloud-firestore