我已經完成了這些不起作用?如何在android中的onCreate()中啓動動畫?
public class AnimationActivity extends Activity{
private AnimationDrawable yourAnimation;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.animation);
getIntentValues();
final ImageView imageView = (ImageView) findViewById(R.id.animation_iv);
imageView.setBackgroundResource(R.drawable.loadinganim);
yourAnimation = (AnimationDrawable) imageView.getBackground();
yourAnimation.start();
}
RES \抽拉\ loading.xml
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<item android:drawable="@drawable/v1" android:duration="160" />
<item android:drawable="@drawable/v4" android:duration="160" />
<item android:drawable="@drawable/v7" android:duration="160" />
<item android:drawable="@drawable/v8" android:duration="160" />
<item android:drawable="@drawable/v9" android:duration="160" />
<item android:drawable="@drawable/v10" android:duration="160" />
<item android:drawable="@drawable/v11" android:duration="160" />
</animation-list>
RES \佈局\ animation.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ImageView
android:id="@+id/animation_iv"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
動畫開始於ImageView的的onClick()。如果有的話一個人有想法幫助我。
我的代碼或例子對您有用嗎? – Praveenkumar 2012-01-31 04:01:09