【发布时间】:2014-10-30 18:38:50
【问题描述】:
我正在尝试将 SplashScreen 添加到我的应用程序中,但我遇到了一个问题: SplashScreen 加载,只是......它不会带我进入主活动。 这是 SplashScreenActivity.java:
import android.app.Activity;
import android.graphics.PixelFormat;
import android.os.Bundle;
import android.view.Window;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.LinearLayout;
public class SplashScreenActivity extends Activity {
public void onAttachedToWindow() {
super.onAttachedToWindow();
Window window = getWindow();
window.setFormat(PixelFormat.RGBA_8888);
}
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
StartAnimations();
}
private void StartAnimations() {
Animation anim = AnimationUtils.loadAnimation(this, R.anim.alpha);
anim.reset();
LinearLayout l=(LinearLayout) findViewById(R.id.lin_lay);
l.clearAnimation();
l.startAnimation(anim);
anim = AnimationUtils.loadAnimation(this, R.anim.translate);
anim.reset();
ImageView iv = (ImageView) findViewById(R.id.logo);
iv.clearAnimation();
iv.startAnimation(anim);
}
}
对不起我的英语。
【问题讨论】:
-
您在哪里完成启动 Activity 并开始主 Activity?
-
所以我猜你只是将启动画面用于动画。在该动画之后,您需要完成初始屏幕活动并启动您的主要活动。除非您启动主要活动,否则它不会加载。
-
@Rohit5k2 知道如何开始我的主要活动吗?
-
@jvrodrigues 已经回答了...如果您不想拖延,请查看我的回答。
标签: android screen splash-screen