1

I sometimes run into the following scenario :

  • I call View.post(Runnable r) and it returns true
  • when calling android.os.Looper.myLooper().dump(...), the runnable seems not in the messageQueue
  • after calling invalidate on the main layout (for example after 20 seconds), the Runnable gets executed

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

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

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.

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.

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

Community
  • 1
  • 1
Marc Van Daele
  • 2,856
  • 1
  • 26
  • 52
  • I noted that, when the post() is not executed immediately, that the view.hasWindowFocus()==false. Does this help answering my questions? – Marc Van Daele Jun 28 '12 at 15:08

1 Answers1

0

The answer is given here ListView.hasWindowFocus==true but child views hasWindowFocus==false

ListView doesn't like an adapter of Views.

Community
  • 1
  • 1
Marc Van Daele
  • 2,856
  • 1
  • 26
  • 52