直接上代碼
專注于為中小企業(yè)提供成都網(wǎng)站設(shè)計(jì)、成都做網(wǎng)站服務(wù),電腦端+手機(jī)端+微信端的三站合一,更高效的管理,為中小企業(yè)鞍山免費(fèi)做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動(dòng)了1000多家企業(yè)的穩(wěn)健成長(zhǎng),幫助中小企業(yè)通過(guò)網(wǎng)站建設(shè)實(shí)現(xiàn)規(guī)模擴(kuò)充和轉(zhuǎn)變。
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 ++; } }