我的splashanimation.java
文件存在问题。它不断在setcontentview
和loadanimation
上抛出错误。如果有人能指出我正在解决这个问题的正确方向,那将非常感激。
我还尝试清理项目以及删除问题错误。似乎没什么用。
我提前道歉,我仍然是Java世界的新手。
这是java文件。
package com.android.club;
import android.content.Intent;
import android.os.Bundle;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.view.animation.LayoutAnimationController;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;
import com.android.club.R;
public class ClubSplashActivity extends ClubActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
startAnimating();
}
private void startAnimating() {
// Fade in top title
TextView TextViewTopTitle = findViewById(R.id.TextViewTopTitle);
Animation fade1 = AnimationUtils.loadAnimation(this, R.anim.fade_in);
TextViewTopTitle.startAnimation(fade1);
// Fade in bottom title after a built-in delay.
TextView TextViewbottomTitle = findViewById(R.id.TextViewbottomTitle);
Animation fade2 = AnimationUtils.loadAnimation(this, R.anim.fade_in2);
TextViewbottomTitle.startAnimation(fade2);
fade2.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationEnd(Animation animation) {
startActivity(new Intent());
ClubSplashActivity.this.finish();
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationStart(Animation animation) {
}
});
Animation spinin = AnimationUtils.loadAnimation(this, R.anim.custom_anim);
LayoutAnimationController controller = new LayoutAnimationController(spinin);
TableLayout table = (TableLayout) findViewById(R.id.TableLayout01);
for (int i = 0; i < table.getChildCount(); i++) {
TableRow row = (TableRow) table.getChildAt(i);
row.setLayoutAnimation(controller);
}
}
protected void startActivity(Intent intent) {
// TODO Auto-generated method stub
}
protected void finish() {
// TODO Auto-generated method stub
}
private TextView findViewById(int textviewtoptitle) {
// TODO Auto-generated method stub
return null;
}
@Override
protected void onPause() {
super.onPause();
TextView logo1 = findViewById(R.id.TextViewTopTitle);
logo1.clearAnimation();
TextView logo2 = findViewById(R.id.TextViewbottomTitle);
logo2.clearAnimation();
TableLayout table = (TableLayout) findViewById(R.id.TableLayout01);
for (int i = 0; i < table.getChildCount(); i++) {
TableRow row = (TableRow) table.getChildAt(i);
row.clearAnimation();
}
}
@Override
protected void onResume() {
super.onResume();
startAnimating();
}
}
这是来自调试的logcat数据。如果这不是正确的信息我道歉。
12-16 17:45:05.891: D/AndroidRuntime(944): Shutting down VM
12-16 17:45:05.891: W/dalvikvm(944): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
12-16 17:45:06.011: E/AndroidRuntime(944): FATAL EXCEPTION: main
12-16 17:45:06.011: E/AndroidRuntime(944): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.android.club/com.android.club.ClubActivity}: java.lang.ClassCastException: com.android.club.ClubActivity cannot be cast to android.app.Activity
12-16 17:45:06.011: E/AndroidRuntime(944): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
12-16 17:45:06.011: E/AndroidRuntime(944): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
12-16 17:45:06.011: E/AndroidRuntime(944): at android.app.ActivityThread.access$600(ActivityThread.java:141)
12-16 17:45:06.011: E/AndroidRuntime(944): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
12-16 17:45:06.011: E/AndroidRuntime(944): at android.os.Handler.dispatchMessage(Handler.java:99)
12-16 17:45:06.011: E/AndroidRuntime(944): at android.os.Looper.loop(Looper.java:137)
12-16 17:45:06.011: E/AndroidRuntime(944): at android.app.ActivityThread.main(ActivityThread.java:5041)
12-16 17:45:06.011: E/AndroidRuntime(944): at java.lang.reflect.Method.invokeNative(Native Method)
12-16 17:45:06.011: E/AndroidRuntime(944): at java.lang.reflect.Method.invoke(Method.java:511)
12-16 17:45:06.011: E/AndroidRuntime(944): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
12-16 17:45:06.011: E/AndroidRuntime(944): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
12-16 17:45:06.011: E/AndroidRuntime(944): at dalvik.system.NativeStart.main(Native Method)
12-16 17:45:06.011: E/AndroidRuntime(944): Caused by: java.lang.ClassCastException: com.android.club.ClubActivity cannot be cast to android.app.Activity
12-16 17:45:06.011: E/AndroidRuntime(944): at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
12-16 17:45:06.011: E/AndroidRuntime(944): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
12-16 17:45:06.011: E/AndroidRuntime(944): ... 11 more