Summary of several methods of Android UI update

Android UI update

People who have done Android development have encountered such problems: with the change of demand, some entry interfaces will have problems such as UI increase or decrease, content change and jump interface change. Here are several methods to update the UI.

1. Runonuithread of activity

Android activity runonuithread() method uses

2、Handler sendEmptyMessage()

3、Handler post()

Switch to the main thread in the child thread

Results

It can be seen that this method can quickly switch threads. From the log, switching to the main thread will not block sub threads.

4、view Post() 

Summary:

1. In fact, the above four methods can be attributed to one method: handler is used for communication between Android threads.

2. Why does Android require UI operations only in UI threads? Mainly to avoid the concurrency problem caused by multithreading. It is safe to operate the UI in a single thread.

Thank you for reading, hope to help you, thank you for your support to this site!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>