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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

用handler.postDelay();更改圖片,我的會(huì)崩潰

package?com.zxx.handler;
import?android.R.integer;
import?android.app.Activity;
import?android.os.Bundle;
import?android.os.Handler;
import?android.view.Menu;
import?android.view.MenuItem;
import?android.widget.ImageView;
import?android.widget.TextView;
public?class?MainActivity?extends?Activity?{
?private?TextView?tvTextView;
?private?ImageView?ivImageView;
?private?int?index;
?private?MyRunnable?mrMyRunnable?=?new?MyRunnable();
?private?Handler?mHandler?=?new?Handler();
?private?int?images[]?=?{R.drawable.ic_launcher,R.drawable.ic_launcher1};
class?MyRunnable?implements?Runnable{
?@Override
?public?void?run()?{
??//?TODO?Auto-generated?method?stub
??index++;
??index=index%3;
?????ivImageView.setImageResource(images[index]);
??mHandler.postDelayed(mrMyRunnable,?1000);
?}
}
????@Override
????protected?void?onCreate(Bundle?savedInstanceState)?{
????????super.onCreate(savedInstanceState);
??setContentView(R.layout.activity_main);
??tvTextView?=?(TextView)?findViewById(R.id.tv1);
??ivImageView?=?(ImageView)findViewById(R.id.imageView1);
??mHandler.postDelayed(mrMyRunnable,?1000);
//??new?Thread(){
//???public?void?run()?{
//????try?{
//?????Thread.sleep(1000);
//?????mHandler.post(new?Runnable()?{
//??????
//??????@Override
//??????public?void?run()?{
//???????//?TODO?Auto-generated?method?stub
//???????tvTextView.setText("用handler更新了ui");
//???????
//??????}
//?????});
//????}?catch?(InterruptedException?e)?{
//?????//?TODO?Auto-generated?catch?block
//?????e.printStackTrace();
//????}
//???};
//??}.start();
????}
}


正在回答

1 回答

我知道了,我只有2個(gè)圖,我卻寫的%3,我改成%2就對(duì)了,哈哈

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消
Android面試常客Handler詳解
  • 參與學(xué)習(xí)       54867    人
  • 解答問題       192    個(gè)

學(xué)Android開發(fā),必學(xué)Handler,也是Android面試???/p> 進(jìn)入課程

用handler.postDelay();更改圖片,我的會(huì)崩潰

我要回答 關(guān)注問題
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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