Android開発初心者です。このコードを書きましたが、アプリがクラッシュする原因がわかりません。アクティビティを一時停止できなかったことを示しています。私はそれが私が除外しているものだと確信しています。過去に機能した非常によく似たコードを書いたので、どこから始めればよいかわかりません。
SplashActivity.java
public class SplashActivity extends Activity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
ImageView logo = (ImageView) findViewById(R.id.ImageViewLogo);
Animation twistIn = AnimationUtils.loadAnimation(this, R.anim.twist_in);
logo.startAnimation(twistIn);
twistIn.setAnimationListener(new AnimationListener()
{
public void onAnimationStart(Animation animation)
{
return; // do nothing
}
public void onAnimationRepeat(Animation animation)
{
return; // do nothing
}
public void onAnimationEnd(Animation animation)
{
startActivity(new Intent(SplashActivity.this, MenuActivity.class));
SplashActivity.this.finish();
}
});
}
@Override
protected void onPause()
{
super.onPause();
TextView logo = (TextView) findViewById(R.id.ImageViewLogo);
logo.clearAnimation();
}
}
そして、これがLogCatの不平です:
04-04 02:09:10.460: W/dalvikvm(12531): threadid=1: thread exiting with uncaught exception (group=0x4001e578)
04-04 02:09:10.480: E/AndroidRuntime(12531): FATAL EXCEPTION: main
04-04 02:09:10.480: E/AndroidRuntime(12531): java.lang.RuntimeException: Unable to pause activity {com.swapwords/com.swapwords.SplashActivity}: java.lang.ClassCastException: android.widget.ImageView
04-04 02:09:10.480: E/AndroidRuntime(12531): at android.app.ActivityThread.performPauseActivity(ActivityThread.java:2358)
04-04 02:09:10.480: E/AndroidRuntime(12531): at android.app.ActivityThread.performPauseActivity(ActivityThread.java:2315)
04-04 02:09:10.480: E/AndroidRuntime(12531): at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:2295)
04-04 02:09:10.480: E/AndroidRuntime(12531): at android.app.ActivityThread.access$1700(ActivityThread.java:117)
04-04 02:09:10.480: E/AndroidRuntime(12531): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:942)
04-04 02:09:10.480: E/AndroidRuntime(12531): at android.os.Handler.dispatchMessage(Handler.java:99)
04-04 02:09:10.480: E/AndroidRuntime(12531): at android.os.Looper.loop(Looper.java:130)
04-04 02:09:10.480: E/AndroidRuntime(12531): at android.app.ActivityThread.main(ActivityThread.java:3691)
04-04 02:09:10.480: E/AndroidRuntime(12531): at java.lang.reflect.Method.invokeNative(Native Method)
04-04 02:09:10.480: E/AndroidRuntime(12531): at java.lang.reflect.Method.invoke(Method.java:507)
04-04 02:09:10.480: E/AndroidRuntime(12531): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
04-04 02:09:10.480: E/AndroidRuntime(12531): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:670)
04-04 02:09:10.480: E/AndroidRuntime(12531): at dalvik.system.NativeStart.main(Native Method)
04-04 02:09:10.480: E/AndroidRuntime(12531): Caused by: java.lang.ClassCastException: android.widget.ImageView
04-04 02:09:10.480: E/AndroidRuntime(12531): at com.swapwords.SplashActivity.onPause(SplashActivity.java:57)
04-04 02:09:10.480: E/AndroidRuntime(12531): at android.app.Activity.performPause(Activity.java:3893)
04-04 02:09:10.480: E/AndroidRuntime(12531): at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1194)
04-04 02:09:10.480: E/AndroidRuntime(12531): at android.app.ActivityThread.performPauseActivity(ActivityThread.java:2345)
04-04 02:09:10.480: E/AndroidRuntime(12531): ... 12 more
04-04 02:09:12.452: I/dalvikvm(12531): threadid=4: reacting to signal 3
04-04 02:09:12.452: I/dalvikvm(12531): Wrote stack traces to '/data/anr/traces.txt'
04-04 02:09:18.878: I/dalvikvm(12531): threadid=4: reacting to signal 3
04-04 02:09:18.878: I/dalvikvm(12531): Wrote stack traces to '/data/anr/traces.txt'
私はただ迷っています。