简体   繁体   English

如何从 firebase 实时数据库中检索两个不同的值并在 onDataChange 方法之外使用?

[英]How can I retrieve two different values from firebase realtime database and use outside onDataChange method?

   int percentint=(vdcostint/b1txtaint)*100;

-------vdcostint is a value retrieved from firebase and b1txtaint is another value from different key--- -------vdcostint 是从 firebase 检索的值,b1txtaint 是来自不同键的另一个值---

But I am unable to use two values outside onDataChange.但我无法在 onDataChange 之外使用两个值。

The values you obtain inside onDataChange() are not available outside the method.您在 onDataChange() 内部获得的值在方法外部不可用。 To use the data outside those values you need to call a function from inside of the onDataChange() and do the calculations there.要使用这些值之外的数据,您需要从 onDataChange() 内部调用一个函数并在那里进行计算。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM