国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Android > 正文

Android中的Looper對象詳細介紹

2020-04-11 11:55:06
字體:
來源:轉載
供稿:網友

Java 官網對Looper對象的說明:


public class Looperextends Object
Class used to run a message loop for a thread. Threads by default do not have a message loop associated with them; to create one, call prepare() in the thread that is to run the loop, and then loop() to have it process messages until the loop is stopped.

Most interaction with a message loop is through the Handler class.

This is a typical example of the implementation of a Looper thread, using the separation of prepare() and loop() to create an initial Handler to communicate with the Looper.

復制代碼 代碼如下:

  class LooperThread extends Thread {
      public Handler mHandler;

      public void run() {
          Looper.prepare();

          mHandler = new Handler() {
              public void handleMessage(Message msg) {
                  // process incoming messages here
              }
          };

          Looper.loop();
      }
  }

主要方法:

static void loop() :  Run the message queue in this thread.
static void prepare() :  Initialize the current thread as a looper.

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 柘荣县| 彰武县| 湟中县| 额尔古纳市| 岱山县| 庐江县| 盐池县| 新宁县| 厦门市| 山丹县| 伊春市| 渑池县| 黎平县| 延庆县| 武强县| 乌拉特中旗| 南溪县| 正阳县| 美姑县| 剑河县| 海阳市| 汨罗市| 滕州市| 稷山县| 桓仁| 孝昌县| 长宁区| 清原| 承德市| 延津县| 西畴县| 大连市| 英超| 沁水县| 忻州市| 云龙县| 柳河县| 阜新| 乐平市| 开远市| 东港市|