Messages

 

To send a to a , first invoke to get the object out of the pool. There are a few flavors of , allowing you to just create empty objects, or ones populated with message identifiers and arguments. The more complicated your processing needs to be, the more likely it is you will need to put data into the to help the distinguish different events.

Then, you send the to the via its message queue, using one of the following family of methods:

• puts the message on the queue immediately

• puts the message on the queue immediately, and moreover puts it at the front of the message queue (versus the back, as is the default), so your message takes priority over all others

• puts the message on the queue at the stated time, expressed in the form of milliseconds based on system uptime ()

• puts the message on the queue after a delay, expressed in milliseconds

To process these messages, your needs to implement , which will be called with each message that appears on the message queue. There, the handler can update the UI as needed. However, it should still do that work quickly, as other UI work is suspended until the is done.

For example, let’s create a and update it via a . Here is the layout from the sample project. This sample code along with all others in this chapter can be found in the Source Code section at http://apress.com.

 

The , in addition to setting the width and height as normal, also employs the property, which I won’t cover in detail in this book. Suffice it to say, property indicates this should be drawn as the traditional horizontal bar showing the amount of work that has been completed.

Here is the Java:








Дата добавления: 2015-05-16; просмотров: 699;


Поиск по сайту:

При помощи поиска вы сможете найти нужную вам информацию.

Поделитесь с друзьями:

Если вам перенёс пользу информационный материал, или помог в учебе – поделитесь этим сайтом с друзьями и знакомыми.
helpiks.org - Хелпикс.Орг - 2014-2024 год. Материал сайта представляется для ознакомительного и учебного использования. | Поддержка
Генерация страницы за: 0.003 сек.