在我的应用程序中,我创建了一个闪屏类型的东西在android中。它应该保持5秒钟。我的问题是如何在5秒后自动显示其他活动?启动画面没有按钮,相反它应该在5秒后自动显示另一个活动,而不需要点击按钮。并且请指导我如何设计新的全屏活动。我从堆栈溢出得到了这段代码,但由于我是初学者,我不知道在哪里添加这段代码,任何人都可以告诉我。全屏活动设计和自动启动新活动
-4
A
回答
0
你可以找到关于本教程如何创建启动画面:https://www.youtube.com/watch?v=XwOuTjUFexE
0
开机画面加载添加下面的代码之后在上创建
try {
Thread.sleep(5000);// You can change this depending on the requirement
Intent intent = new Intent(SplashActivity.this,SecondActivity.class);
startActivity(intent);
finish();
} catch (InterruptedException e) {
e.printStackTrace();
}
你的第二个活动将在5秒钟后自动被加载。
为了使活动全屏的setContentView前添加以下线:
getWindow()setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.your_activity_layout);
}
1
因此可以说你已经为你的闪屏创建了一个布局。 然后你需要为你的启动画面创建一个活动。
public class SplashScreen extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash); //The layout for this activity
Thread timerThread = new Thread(){
public void run(){
try {
sleep(5000); //After 5 seconds your next activity will be displayed
} catch(InterruptedException e){
e.printStackTrace();
} finally {
Intent intent = new Intent(getBaseContext, MainActivity.class); // The next activity you want to start
startActivity(intent);
}
}
};
timerThread.start();
}
@Override
protected void onPause() {
super.onPause();
finish();
}}
然后remeber编辑您的活动类别在AndroidManifest.xml文件的启动画面类别应该是.LAUNCHER,而你的主要活动应.DEFAULT
<activity
android:name=".SplashScreen"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.example.MAINACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
0
使用闪屏验证码活动更改时间如你所愿......
public class SplashScreen extends Activity {
// Splash screen timer
private static int SPLASH_TIME_OUT = 3000;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
new Handler().postDelayed(new Runnable() {
/*
* Showing splash screen with a timer. This will be useful when you
* want to show case your app logo/company
*/
@Override
public void run() {
// This method will be executed once the timer is over
// Start your app main activity
Intent i = new Intent(SplashScreen.this, Login_Activity.class);
startActivity(i);
//overridePendingTransition(R.anim.fadein,R.anim.fadeout);
// close this activity
finish();
}
}, SPLASH_TIME_OUT);
}
}
相关问题
- 1. 全屏启动wifi设置活动
- 2. 非全屏滚动活动
- 3. 启动活动时自动刷新
- 4. 非全屏活动
- 5. 如何在重新启动后立即启动锁屏活动?
- 6. Android活动重新启动
- 7. Android - 无法在设备启动时自动启动活动?
- 8. 启动活动
- 9. 设计滑动活动android
- 10. 活动的onStop()在启动另一个全屏时未被调用活动
- 11. 当移动到活动时自动启动倒计时
- 12. Android活动自动启动 - 不需要
- 13. 真正的全屏活动
- 14. 如何做全屏活动?
- 15. Android活动设计
- 16. 启动InCallScreen活动
- 17. Box2d:设置活动和不活动
- 18. 启动活动超时,因为活动启动另一个活动
- 19. 如何从其他活动启动启动器活动?
- 20. 将当前活动设置为启动活动
- 21. 在不重新启动活动的情况下恢复活动
- 22. 启动新活动时发生绑定事务失败活动
- 23. 安卓4.2:主要活动actionbar隐藏启动新的活动
- 24. 关闭父活动并启动一个新活动
- 25. 使用活动组时,无法从alertdialog onclicklistener启动新活动
- 26. 半屏活动
- 27. 活动和子活动
- 28. WPF活动和活动
- 29. 启动器启动的活动,自定义动画
- 30. 活动启动时自动启动执行
不如海在谷歌''如何处理Splash屏幕在Android?' –
可能重复的[如何设置我的启动画面的时间限制?](http://stackoverflow.com/questions/19491073/how-do-i -set-A-时限到我,闪屏) –