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

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

Android SplashScreen 在 ImageView 中更改圖像

Android SplashScreen 在 ImageView 中更改圖像

手掌心 2021-11-11 16:36:11
我是安卓初學(xué)者。我每 2 秒就在 ImageView 中制作了一個(gè) SplashScreen 更改 img 圖片。最后一個(gè)圖像連續(xù)顯示兩次,以避免在移動(dòng)到 MainActivity 之前立即消失。所以它以某種方式工作 - 圖片正在改變,最后它把用戶帶到 MainActivity 那里我只有一個(gè)什么都不做的按鈕(只是為了測(cè)試在那里可見)。理論上一切都很好,但每 8 秒 MainActivity 可能會(huì)再次重新加載。我可以看到因?yàn)?Button 上下跳動(dòng) 1px。你能看看我的代碼并回答為什么嗎?謝謝你!public class SplashScreen extends Activity {@Overrideprotected void onCreate(Bundle savedInstanceState) {    super.onCreate(savedInstanceState);    this.requestWindowFeature(Window.FEATURE_NO_TITLE);    this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);    setContentView(R.layout.activity_splash_screen);    handler.postDelayed(runnable, 0);}@Overrideprotected void onDestroy() {    super.onDestroy();}int[] imageArraySplashScreen = { R.drawable.pierwszy, R.drawable.drugi, R.drawable.trzeci, R.drawable.trzeci};Handler handler = new Handler();Runnable runnable = new Runnable(){    int i = 0;    ImageView splashImageView;    public void run() {        splashImageView = findViewById(R.id.idSplashScreenImageView);        splashImageView.setImageResource(imageArraySplashScreen[i]);        i++;        if (i>imageArraySplashScreen.length-1){            i=0;            Intent splashScreenIntent = new Intent(SplashScreen.this, MainActivity.class );            startActivity(splashScreenIntent);            finish();        }        handler.postDelayed(this, 2000);    }};}
查看完整描述

2 回答

?
烙印99

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

嘗試

handler.removeCallbacks(runnable);

在 onPause()


查看完整回答
反對(duì) 回復(fù) 2021-11-11
?
墨色風(fēng)雨

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

僅當(dāng)圖像要顯示時(shí)才需要發(fā)布處理程序。只需更改您的代碼,例如,


Handler handler = new Handler();    

Runnable runnable = new Runnable() {

        int i = 0;

        ImageView splashImageView;


        public void run() {


            splashImageView.setImageResource(imageArraySplashScreen[i]);

            i++;

            if (i > imageArraySplashScreen.length - 1) {

                i = 0;

                Intent splashScreenIntent = new Intent(SplashScreen.this, MainActivity.class);

                startActivity(splashScreenIntent);

                finish();

            } else {

                handler.postDelayed(this, 2000);

            }


        }

    };


查看完整回答
反對(duì) 回復(fù) 2021-11-11
  • 2 回答
  • 0 關(guān)注
  • 164 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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