所以,我是用android編程的新手,我試圖做的第一件事就是創建一個基本的動畫,它自己開始。沒有什麼複雜的,只是一個循環動畫。我試圖堅持一幀一幀,因爲它似乎是最基本和最容易理解的。我已經看過很多教程/網站/視頻(包括android開發網站)如何做到這一點,不知道我做錯了什麼。我確定我有一個簡單的邏輯錯誤。以下是我發佈的代碼。有人可以幫我嗎?感謝您的幫助! (另外,根據Nook開發者網站的說法,這個特別是在NookColor模擬器上運行,nook運行最新的android。不幸的是Nook網站沒有提供任何教程或者任何有用的東西,只有和Android開發者有相同的鏈接。)Android動畫 - 逐幀?
//main class
public class WallpaperActivity extends Activity {
AnimationDrawable animSequence;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageView animImg = (ImageView) findViewById(R.id.animatepic);
animImg.setBackgroundResource(R.drawable.animation);
animSequence = (AnimationDrawable) animImg.getBackground();
}
@Override
public void onWindowFocusChanged(boolean hasFocus)
{
super.onWindowFocusChanged(hasFocus);
animSequence.start();
}
}
//animation.xml class (<< this is not my main.xml class)
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/animatepic" android:oneshot="false" >
<item android:drawable="@drawable/a" android:duration="200" />
<item android:drawable="@drawable/b" android:duration="200" />
<item android:drawable="@drawable/c" android:duration="200" />
<item android:drawable="@drawable/d" android:duration="200" />
<item android:drawable="@drawable/e" android:duration="200" />
<item android:drawable="@drawable/f" android:duration="200" />
<item android:drawable="@drawable/g" android:duration="200" />
<item android:drawable="@drawable/h" android:duration="200" />
<item android:drawable="@drawable/i" android:duration="200" />
<item android:drawable="@drawable/j" android:duration="200" />
<item android:drawable="@drawable/k" android:duration="200" />
<item android:drawable="@drawable/l" android:duration="200" />
<item android:drawable="@drawable/m" android:duration="200" />
<item android:drawable="@drawable/n" android:duration="200" />
<item android:drawable="@drawable/o" android:duration="200" />
</animation-list>
您是否收到任何錯誤或動畫,無法啓動... –
我得到的是模擬器將加載,然後它會說,應用程序必須是「唯一的反饋強制關閉「 – Derek