Android: When to use Button.Post?

依然范特西╮ 提交于 2019-12-25 07:47:24

问题


I noticed a method called Post in Android's Button class. I was wondering what this method was for? This method takes a runnable argument, my question is when should we use this vs just having a listener bind to the click event of this button? What is the difference? Any example is appreciated.


回答1:


post() is inherited from View. It has nothing to do with button clicks and is not a replacement for an OnClickListener. post() is used to arrange for a Runnable to be executed on the main application thread, typically by some code running on a background thread.



来源:https://stackoverflow.com/questions/8717145/android-when-to-use-button-post

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!