小编Mar*_*ini的帖子

在Android中等待Firebase异步检索数据

我需要存储他自己异步的FireBase getValue方法的结果.我不能使用类似"onPostExecute()"的东西,为了我的目的,我无法执行"onDataChange()"的所有操作,因为我需要在将来的其他活动中引用一些参考.

这是我的片段检索数据:

    List<Village> villages = new LinkedList<>();
    Firebase ref = new Firebase("MYFIREBASEURL").child("village");
    ref.addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot snapshot) {
            spinnerArray.clear();
            for (DataSnapshot postSnapshot : snapshot.getChildren()) {
                Village v = postSnapshot.getValue(Village.class);
                villages.add(v);
            }
        }

        @Override
        public void onCancelled(FirebaseError firebaseError) {
            System.out.println("The read failed: " + firebaseError.getMessage());
        }
    });
Run Code Online (Sandbox Code Playgroud)

如果我尝试从"onDataChange"中读取村庄,我自然会为他的异步生活读取空值.有一种方法可以确保调用onDataChange吗?

android synchronization asynchronous firebase firebase-realtime-database

10
推荐指数
1
解决办法
1万
查看次数

斯威夫特如何隐藏元素和他的空间

我希望标题清楚.我想隐藏一个元素(在我的情况下是数据选择器),我也想隐藏他的空间.所以我用动画尝试了这个:

    @IBAction func showQnt(sender: AnyObject) {
    if (self.pickerQnt.alpha == 0.0){
        UIView.animateWithDuration(0.2, delay: 0.0, options: UIViewAnimationOptions.ShowHideTransitionViews, animations: {
            self.pickerQnt.alpha = 1.0


            }, completion: {
                (finished: Bool) -> Void in
                //var constH = NSLayoutConstraint(item: self.pickerQnt, attribute: NSLayoutAttribute.Height, relatedBy: NSLayoutRelation.Equal, toItem: nil, attribute: NSLayoutAttribute.NotAnAttribute, multiplier: 1, constant: 162)
                //self.pickerQnt.addConstraint(constH)
        })
    } else {
        UIView.animateWithDuration(0.2, delay: 0.0, options: UIViewAnimationOptions.ShowHideTransitionViews, animations: {
            self.pickerQnt.alpha = 0.0


            }, completion: {
            (finished: Bool) -> Void in
                // CHECK: ?!? constrain to set view height to 0 run time …
Run Code Online (Sandbox Code Playgroud)

hide ios swift

8
推荐指数
2
解决办法
7998
查看次数

漫画中的逗号用法

@IBAction func selectedGame(segue:UIStoryboardSegue) {
  if let gamePickerViewController = segue.sourceViewController as? GamePickerViewController,
    selectedGame = gamePickerViewController.selectedGame {
    detailLabel.text = selectedGame
    game = selectedGame
  }
}
Run Code Online (Sandbox Code Playgroud)

大家好,我正在学习一些关于swift的教程.昨天我发现了这部分代码,但我找不到理解这意味着什么意思的方法.你可以解释一下吗?

comma swift

5
推荐指数
1
解决办法
3161
查看次数