【问题标题】:Firebase - can't use setValue() on LHS of assignment?Firebase - 不能在分配的 LHS 上使用 setValue()?
【发布时间】:2015-11-27 10:38:41
【问题描述】:

我使用的是 Android Studio 1.5,并直接使用文档本身中的以下代码

  public class User {
        private int birthYear;
        private String fullName;

        public User() {
        }

        public User(String fullName, int birthYear) {
            this.fullName = fullName;
            this.birthYear = birthYear;
        }

        public long getBirthYear() {
            return birthYear;
        }

        public String getFullName() {
            return fullName;
        }
    }

Firebase 代码

Firebase ref = new Firebase("https://docs-examples.firebaseio.com/android/saving-data/fireblog");
Firebase alanRef = ref.child("users").child("alanisawesome");
User alan = new User("Alan Turing", 1912);
alanRef.setValue(alan);

它会抛出错误cannot resolve symbol setValue。当我尝试自动完成功能时,没有建议 setValue(); 但是如果在赋值操作的 RHS 上使用,如下面的代码所示,它可以工作。有人可以帮我吗?

 Firebase abc = ref.setValue(); //seems to work   

【问题讨论】:

标签: android firebase


【解决方案1】:

我没有看到你的整个代码,但我假设你尝试在方法之外使用 setValue。 setValue 方法只能在方法内部调用。

【讨论】:

    猜你喜欢
    • 2020-06-06
    • 1970-01-01
    • 2023-03-18
    • 1970-01-01
    • 1970-01-01
    • 2011-11-23
    • 1970-01-01
    • 2017-05-02
    相关资源
    最近更新 更多