发布成功了Runnable仅被执行时,父母是无效的 [英] successfully posted Runnable only gets executed when parent is invalidated

查看:166
本文介绍了发布成功了Runnable仅被执行时,父母是无效的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有时会遇到以下情况:

I sometimes run into the following scenario :

  • 在我打电话View.post(Runnable的r)和返回true
  • 在调用android.os.Looper.myLooper()。转储(......)时,可运行似乎没有在messageQueue
  • 在调用(20秒后为例)无效的主要布局后,Runnable对象被执行

这只是发生不时,它发生在多台设备上的多个Android的版本。

This only happens from time to time, it happens on multiple devices and on multiple Android versions.

这个问题似乎类似于<一href="http://stackoverflow.com/questions/4083787/runnable-is-posted-successfully-but-not-run">Runnable成功发布,但不运行和<一href="http://stackoverflow.com/questions/4327783/android-button-within-listview-not-receiving-onclick-events">Android:在ListView控件按钮不接收的onClick事件

The problem seems similar to Runnable is posted successfully but not run and Android: Button within ListView not receiving onClick events

有人可以解释在何种情况下一个Runnable被公布,但不会被执行(但)?为什么它没有一个(父)无效后得到执行。

Can somebody explain under which circumstances a Runnable gets posted but doesn't get executed (yet)? And why it does get executed after a (parent) invalidate.

注:使用runOnUiThread工作正常,但我不能使用此发布了Runnable:我的真正的问题是,有时OnClickListener不叫;这是追查到来电来邮(performClick)在View.onTouchEvent。

Note: Posting the Runnable using runOnUiThread works fine but I can't use this: my real problem is that sometimes the OnClickListener is not called; this was tracked down to the call to post(performClick) in View.onTouchEvent.

我想我的看法层次是在一些奇怪的状态,但我无言以对。
我的意见是在code创建,并大致包括

I assume my View hierarchy is in some weird state but I'm clueless.
My Views are created in code and roughly consists of

  • RelativeLayout
  • ListView
  • HorizontalListView (from http://www.dev-smart.com/archives/34)
  • MyOwnView

推荐答案

答案就在这里<给定href="http://stackoverflow.com/questions/11257357/listview-haswindowfocus-true-but-child-views-haswindowfocus-false">ListView.hasWindowFocus==true但孩子的意见hasWindowFocus ==虚假

ListView控件不喜欢浏览的适配器。

ListView doesn't like an adapter of Views.

这篇关于发布成功了Runnable仅被执行时,父母是无效的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆