首页 \ 问答 \ 迭代Firebase阵列(Iterating Through Firebase Array)

迭代Firebase阵列(Iterating Through Firebase Array)

当我得到数据库的快照时,我看到了这个:

{
    "9-17-2017" =     {
        "19:26:38" =         {
            1abA = 1ab;
            1abrA = 1;
            2abA = 2ab;
            2abrA = 2;
            3abA = 3ab;
            4abA = 4ab;
            5abA = 5a;
            6abA = 6ab;
            7abA = 7ab;
            Date = "9-17-2017";
            Time = "19:26:38";
            anA = an;
            apnA = apn;
            q1A = 1;
            q2A = 2;
            q3A = 3;
            q4A = 4;
            q5A = 5;
            q6A = 6;
        };
        "20:16:15" =         {
            1abA = 1qwe;
            1abrA = 3;
            2abA = "D.C.";
            2abrA = 7;
            3abA = wedded;
            4abA = wedge;
            5abA = qdwfeg;
            6abA = qwfegr;
            7abA = wedge;
            Date = "9-17-2017";
            Time = "20:16:15";
            anA = "we're";
            apnA = apn;
            q1A = 7;
            q2A = 2;
            q3A = 7;
            q4A = 4;
            q5A = 5;
            q6A = 7;
        };
    };
}

我希望能够将标签设置为键1abA的值,但我似乎无法找到一种方法来对数组进行排序。

我正在使用此代码来获取快照:

let userID = Auth.auth().currentUser?.uid
let ref = Database.database().reference().child("users").child(userID!) ref.child("PostGameEval").observe(.value, with: { (snapshot) in
            print(snapshot.value!)
        })

When I get a snapshot of the database I see this:

{
    "9-17-2017" =     {
        "19:26:38" =         {
            1abA = 1ab;
            1abrA = 1;
            2abA = 2ab;
            2abrA = 2;
            3abA = 3ab;
            4abA = 4ab;
            5abA = 5a;
            6abA = 6ab;
            7abA = 7ab;
            Date = "9-17-2017";
            Time = "19:26:38";
            anA = an;
            apnA = apn;
            q1A = 1;
            q2A = 2;
            q3A = 3;
            q4A = 4;
            q5A = 5;
            q6A = 6;
        };
        "20:16:15" =         {
            1abA = 1qwe;
            1abrA = 3;
            2abA = "D.C.";
            2abrA = 7;
            3abA = wedded;
            4abA = wedge;
            5abA = qdwfeg;
            6abA = qwfegr;
            7abA = wedge;
            Date = "9-17-2017";
            Time = "20:16:15";
            anA = "we're";
            apnA = apn;
            q1A = 7;
            q2A = 2;
            q3A = 7;
            q4A = 4;
            q5A = 5;
            q6A = 7;
        };
    };
}

I want to be able to set a label to the value of the key 1abA but I can't seem to figure out a way to sort through the array.

I am using this code to get the snapshot:

let userID = Auth.auth().currentUser?.uid
let ref = Database.database().reference().child("users").child(userID!) ref.child("PostGameEval").observe(.value, with: { (snapshot) in
            print(snapshot.value!)
        })

原文:https://stackoverflow.com/questions/46270028
更新时间:2024-01-14 17:01

最满意答案

文档所述,您应该等到视图附加到窗口后再开始动画。 因此,您应该将OnAttachStateChangeListener添加到将在附加时执行的视图,并从那里开始动画。

ImageView img = (ImageView)v.findViewById(R.id.image);
img.setBackgroundResource(R.drawable.anim);
img.addOnAttachStateChangeListener(new  View.OnAttachStateChangeListener() {
  @Override
  public void onViewAttachedToWindow(View v) {
  AnimationDrawable animation = (AnimationDrawable) v.getBackground();
  animation .start();
  }

@Override
public void onViewDetachedFromWindow(View v) {
}
});

如果您使用的是GIF,请使用Movie Class。 这里有一些学习链接, 这个也是这个问题


i have found my problem !

i had used GamePic.setImageResource(Resources2.GamePicArray[position]);

but i should use

GamePic.setBackgroundResource(Resources2.GamePicArray[position]);

now it works fine !

相关问答

更多
  • 为此运行你的网格动画类应该设置为none for this to run your mesh's animation class should be set to none
  • 调用clearAnimation() , View您调用的startAnimation() 。 Call clearAnimation() on whichever View you called startAnimation().
  • 你的代码看起来不错。 您可以运行以下代码以查看它是否正常工作: fade-in { opacity:0; -webkit-animation:fadeIn ease-in 1; -moz-animation:fadeIn ease-in 1; animation:fadeIn ease-in 1; -webkit-animation-fill-mode:forwards; -moz-animation-fill-mode:forwards ...
  • 如果我错了,请纠正我,但我看到你试图在image1内部step启动动画的唯一原因是因为你希望它在image2动画中途完成时启动。 由于您已定义动画持续时间,因此可以使用简单的$.delay : function startAnimation() { $(".slide div.image2") .animate({left: wWidth / 4, opacity: 1}, 1800) .animate({left: -wWidth, opacity: 0}, 100 ...
  • 如文档所述,您应该等到视图附加到窗口后再开始动画。 因此,您应该将OnAttachStateChangeListener添加到将在附加时执行的视图,并从那里开始动画。 ImageView img = (ImageView)v.findViewById(R.id.image); img.setBackgroundResource(R.drawable.anim); img.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener( ...
  • 在背景图像的情况下,动画不起作用。 Firefox不支持在背景图像之间进行插值。 这就解释了为什么你的代码在background-color情况下适用于所有浏览器,以及为什么在background-image情况下它不适用 请参阅此条目: https : //bugzilla.mozilla.org/show_bug.cgi? id = 1036761和http://forums.mozillazine.org/viewtopic.php?f=25&t=2699753 CSS: .truck-size { ...
  • 您对此类问题进行故障排除的方法是将查询分解为多个部分,直到找到问题的根源。 有时您可能需要在连接中使用select *或指定列,或者在最终产品中未返回的where子句中查看正在进行的操作。 我会做类似下面的事情,运行每一个,直到你看到记录掉落的地方: SELECT username FROM tbl_name WHERE publishedapp = \"Mencap@Work2-1\" SELECT * FROM tbl_name WHERE username in ( SELECT ...
  • 为什么延迟不起作用? Less循环没有问题。 实际问题在于通过代码设置animation-delay值的方式以及它与预期值的不同之处。 根据CSS规范,对于任何时间值,数字和单位之间应该没有空格。 引用MDN : CSS数据类型表示以秒或毫秒表示的时间维度。 它们由紧随其后的单位组成。 与任何CSS维度一样,单位字面值与数字之间没有空格。 减去 - 以下是用于设置延迟值的较少代码。 animation-delay : @delay s; 编译的CSS - 编译上面的Less代码时,您将获得 ...
  • 更好地使用alpha。 UIImageView *iv = self.imageView; ZGCBubbleView *bubbleView = [[ZGCBubbleView alloc] init]; bubbleView.alpha = 0; // bubbleView.hidden = YES; [iv addSubview:bubbleView]; // UIView animation test [UIView animateWithDuration:2.0 ...
  • 只需添加position: relative; 你的#text div是这样的: #text { color: red; z-index: 10; background: transparent; position: relative; } 链接到jsFiddle: https ://jsfiddle.net/AndrewL32/e35xu520/3/ Just add position: relative; to your #text div like this: #te ...

相关文章

更多

最新问答

更多
  • 如何使用自由职业者帐户登录我的php网站?(How can I login into my php website using freelancer account? [closed])
  • 如何打破按钮上的生命周期循环(How to break do-while loop on button)
  • C#使用EF访问MVC上的部分类的自定义属性(C# access custom attributes of a partial class on MVC with EF)
  • 如何获得facebook app的publish_stream权限?(How to get publish_stream permissions for facebook app?)
  • 如何并排放置两个元件?(How to position two elements side by side?)
  • 在MySQL和/或多列中使用多个表用于Rails应用程序(Using multiple tables in MySQL and/or multiple columns for a Rails application)
  • 如何隐藏谷歌地图上的登录按钮?(How to hide the Sign in button from Google maps?)
  • Mysql左连接旋转90°表(Mysql Left join rotate 90° table)
  • 带有ImageMagick和许多图像的GIF动画(GIF animation with ImageMagick and many images)
  • 电脑高中毕业学习去哪里培训
  • 电脑系统专业就业状况如何啊?
  • IEnumerable linq表达式(IEnumerable linq expressions)
  • 如何在Spring测试中连接依赖关系(How to wire dependencies in Spring tests)
  • Solr可以在没有Lucene的情况下运行吗?(Can Solr run without Lucene?)
  • 如何保证Task在当前线程上同步运行?(How to guarantee that a Task runs synchronously on the current thread?)
  • 在保持每列的类的同时向数据框添加行(Adding row to data frame while maintaining the class of each column)
  • 的?(The ? marks in emacs/haskell and ghc mode)
  • 一个线程可以调用SuspendThread传递自己的线程ID吗?(Can a thread call SuspendThread passing its own thread ID?)
  • 延迟socket.io响应,并“警告 - websocket连接无效”(Delayed socket.io response, and “warn - websocket connection invalid”)
  • 悬停时的图像转换(Image transition on hover)
  • IIS 7.5仅显示homecontroller(IIS 7.5 only shows homecontroller)
  • 没有JavaScript的复选框“关闭”值(Checkbox 'off' value without JavaScript)
  • java分布式框架有哪些
  • Python:填写表单并点击按钮确认[关闭](Python: fill out a form and confirm with a button click [closed])
  • PHP将文件链接到根文件目录(PHP Linking Files to Root File Directory)
  • 我如何删除ListView中的项目?(How I can remove a item in my ListView?)
  • 您是否必须为TFS(云)中的每个BUG创建一个TASK以跟踪时间?(Do you have to create a TASK for every BUG in TFS (Cloud) to track time?)
  • typoscript TMENU ATagParams小写(typoscript TMENU ATagParams lowercase)
  • 武陟会计培训类的学校哪个好点?
  • 从链接中删除文本修饰(Remove text decoration from links)