0
我設置了一個android啓動屏幕到我的應用程序,以便在點擊它之後可以直接移動到加載屏幕(這是一個框架動畫)。問題是我的應用程序直接點擊我的啓動屏幕時關閉。你能告訴我我的程序有什麼問題嗎?從啓動屏幕移動到Android應用程序的加載屏幕
這裏是我的主要活動代碼:
package test.com.myapplication;
import android.app.Activity;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.Toast;
public class MyActivity extends Activity {
private AnimationDrawable frameAnimation;
private ImageView view;
ImageButton start;
RelativeLayout background;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my);
start = (ImageButton) findViewById(R.id.startup);
view = (ImageView) findViewById(R.id.imageAnimation);
frameAnimation = (AnimationDrawable) view.getBackground();
start.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
frameAnimation.start();
}
});
}
}
和我創建的XML文件: 佈局文件:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/back"
tools:context=".MyActivity">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/startup"
android:id="@+id/startup"
/>
<ImageView
android:id="@+id/imageAnimation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true" />
</RelativeLayout>
和動畫文件
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/frame01" android:duration="210"/>
<item android:drawable="@drawable/frame02" android:duration="210"/>
<item android:drawable="@drawable/frame03" android:duration="210"/>
<item android:drawable="@drawable/frame04" android:duration="210"/>
<item android:drawable="@drawable/frame05" android:duration="210"/>
<item android:drawable="@drawable/frame06" android:duration="210"/>
</animation-list>
謝謝,至少現在它不會停止,當我點擊屏幕,而是直接以動畫的第一幀作爲背景開始。這個想法是讓開始菜單出現,然後在點擊屏幕後啓動動畫。 – 2014-10-01 22:01:55