开发者

Thread vs. Adapter for backgroud tasks - which one to prefer and why?

As a total noob to android progr开发者_运维百科amming I was advised to make use of adapters and handlers in order to update a textview periodically rather than thread/sleep. However, I wonder why! Any suggestions?


In Android, you can't update a UI widget outside of the UI thread, so Handler provides a way for a Thread to communicate with the UI. In this approach, you start your thread to generate the view data and pass it to the Handler via a Message. The handler then updates the UI according to the data you sent.

I'm not sure exactly where an adapter would fit into the equation, since those are typically used to connect some data with a view (e.g. ListView and ListAdapter).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜