第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

在Android中制作一個(gè)chronometer計(jì)時(shí)器

在Android中制作一個(gè)chronometer計(jì)時(shí)器

Qyouu 2019-03-19 18:19:39
我想在Android中制作一個(gè)chronometer計(jì)時(shí)器,使用了timer和sheduleAtFixedRate 方法??雌饋?lái)像是在timer的run方法中調(diào)用textview后,程序就會(huì)出錯(cuò)停止運(yùn)行。我用的是以下的代碼,哪里出錯(cuò)了呢?Button boton_iniciar; TextView texto_cronometro; Timer count; int a = 0; public void onCreate(Bundle savedInstanceState) {     super.onCreate(savedInstanceState);     setContentView(R.layout.activity_cronometro);     /**********************/     boton_iniciar = (Button) findViewById(R.id.button1);     texto_cronometro = (TextView) findViewById(R.id.textView1);     count= new Timer("Contador");     boton_iniciar.setOnClickListener(new OnClickListener() {         public void onClick(View v) {             // TODO Auto-generated method stub             count.scheduleAtFixedRate(new TimerTask() {                          @Override                 public void run() {                     // TODO Auto-generated method stub                     a++;                     texto_cronometro.setText(String.valueOf(a));                 }             }, 100, 100);         }     }); }
查看完整描述

3 回答

?
藍(lán)山帝景

TA貢獻(xiàn)1843條經(jīng)驗(yàn) 獲得超7個(gè)贊

更新UI線程之外的用戶界面。
用這些代碼:

<youractivityname>.this.runOnUiThread(new Runnable() {

    public void run() {
        texto_cronometro.setText(String.valueOf(a));
    }
});

代替

texto_cronometro.setText(String.valueOf(a));


查看完整回答
反對(duì) 回復(fù) 2019-04-26
  • 3 回答
  • 0 關(guān)注
  • 638 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)