0
我是一個Android的新手,我正在製作一個老虎機遊戲,但無法弄清楚如何使用老虎機的動畫。現在我正在嘗試使用3個不同png文件進行切換的滾動動畫,並且logcat提供了有關跳幀的一些信息。它只是不改變圖像。對不起我的英語不好。製作動畫從imageview切換圖像(Android)
方法的代碼:
public void animation(){ imageView1.setImageResource(R.drawable.slot1); imageView2.setImageResource(R.drawable.slot2); imageView3.setImageResource(R.drawable.slot3); android.os.SystemClock.sleep(70); imageView1.setImageResource(R.drawable.slot2); imageView2.setImageResource(R.drawable.slot3); imageView3.setImageResource(R.drawable.slot1); android.os.SystemClock.sleep(70); imageView1.setImageResource(R.drawable.slot3); imageView2.setImageResource(R.drawable.slot1); imageView3.setImageResource(R.drawable.slot2); android.os.SystemClock.sleep(70); imageView1.setImageResource(R.drawable.slot1); imageView2.setImageResource(R.drawable.slot2); imageView3.setImageResource(R.drawable.slot3); android.os.SystemClock.sleep(70); imageView1.setImageResource(R.drawable.slot2); imageView2.setImageResource(R.drawable.slot3); imageView3.setImageResource(R.drawable.slot1); android.os.SystemClock.sleep(70); imageView1.setImageResource(R.drawable.slot3); imageView2.setImageResource(R.drawable.slot1); imageView3.setImageResource(R.drawable.slot2); android.os.SystemClock.sleep(70); imageView1.setImageResource(R.drawable.slot1); imageView2.setImageResource(R.drawable.slot2); imageView3.setImageResource(R.drawable.slot3); android.os.SystemClock.sleep(70); imageView1.setImageResource(R.drawable.slot2); imageView2.setImageResource(R.drawable.slot3); imageView3.setImageResource(R.drawable.slot1); android.os.SystemClock.sleep(70); imageView1.setImageResource(R.drawable.slot3); imageView2.setImageResource(R.drawable.slot1); imageView3.setImageResource(R.drawable.slot2); android.os.SystemClock.sleep(70); imageView1.setImageResource(R.drawable.slot1); imageView2.setImageResource(R.drawable.slot2); imageView3.setImageResource(R.drawable.slot3); android.os.SystemClock.sleep(70); }
logcat的:
05-08 17:06:53.230:I /指導(943):跳過74幀! 應用程序可能在其主線程上做了太多工作。
感謝您的回覆:)。請給我一個關於如何在asynctask上運行我的代碼的簡要說明?我剛開始學習android並瞭解有關asynctask的任何內容。 – user3583019
這個鏈接可能會幫助你開始使用這個:http://developer.android.com/reference/android/os/AsyncTask.html – Androidz
我有點得到它,但如果我在單獨的類上運行代碼我將如何使用主要活動的圖像視圖切換其圖像? – user3583019