Android--handler use

Source: Internet
Author: User

Directly on the code

public class mainactivity extends activity {         private int title = 0;     private Handler  Handler = new handler () {    public void handlemessage (Message  MSG)  {                 switch  (msg.what)  {                  case 1:                     updatetitle ();                     break;                 }            };    };            @Override   Protected void oncreate (bundle savedinstancestate)  {  super.oncreate ( Savedinstancestate);   setcontentview (R.layout.activity_main);    timer  Timer =new timer ();   timer.scheduleatfixedrate (New mytask (),  0, 2000);  }  private class MyTask extends TimerTask{   @Override    public void run ()  {   message message = new message ();      message.what = 1;     handler.sendmessage ( Message);     }   }          public void updatetitle () {                settitle ("Handle hello  " + title);     title ++;      }} 

650) this.width=650; "style=" width:369px;float:none;height:602px; "title=" Qq20150228145224.png "alt=" Wkiom1txzfdbaq04aabzq8s8btk207.jpg "src=" http://s3.51cto.com/wyfs02/M00/59/F8/ Wkiom1txzfdbaq04aabzq8s8btk207.jpg "width=" 355 "height=" 602 "/>650" this.width=650; "style=" Float:none; "title=" Qq20150228145233.png "alt=" wkiol1txzv7wwpgnaabzdmqxw6q351.jpg "src=" http://s3.51cto.com/wyfs02/M01/59/F5/ Wkiol1txzv7wwpgnaabzdmqxw6q351.jpg "/>

This article is from the "unrestrained" blog, please be sure to keep this source http://shaotao.blog.51cto.com/7606729/1615951

Android--handler use

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.