Android tutorial: How to make a basic splash screen
发布日期:2021-07-29 10:44:41
浏览次数:19
分类:技术文章
本文共 2207 字,大约阅读时间需要 7 分钟。
The following code will show you how to create a basic splashscreen for your Android application that will stay for 5 seconds. If we don't want to wait we can tap the screen to go directly to the next Activity. Source project is on the bottom of the tutorial.
The project has:
2 Activities
1 Image
0 Animations :-)
Lets go through the code to see how simple it is to make a very basic splash screen for your application.
The splashscreen will be the startup Activity for our application and on application launch a Thread will start that will listen for touch events.
See this blog entry for more information on
public class SplashScreen extends Activity { //how long until we go to the next activity protected int _splashTime = 5000; private Thread splashTread; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.splash); final SplashScreen sPlashScreen = this; // thread for displaying the SplashScreen splashTread = new Thread() { @Override public void run() { try { synchronized(this){ //wait 5 sec wait(_splashTime); } } catch(InterruptedException e) {} finally { finish(); //start a new activity Intent i = new Intent(); i.setClass(sPlashScreen, Main.class); startActivity(i); stop(); } } }; splashTread.start(); } //Function that will handle the touch @Override public boolean onTouchEvent(MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { synchronized(splashTread){ splashTread.notifyAll(); } } return true; }}
转载地址:https://blog.csdn.net/thinkinwm/article/details/9325595 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
哈哈,博客排版真的漂亮呢~
[***.90.31.176]2024年03月27日 13时05分44秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
android开发的取消清空按钮,Android开发实现带清空按钮的EditText示例
2019-04-21
mysql整体会滚_滚mysql
2019-04-21
向mysql数据库中添加批量数据类型_使用JDBC在MySQL数据库中快速批量插入数据
2019-04-21
mssql连接mysql数据库文件_在本地 怎么远程连接MSSQL数据库
2019-04-21
mssql 远程无法连接mysql_解决SQLServer远程连接失败的问题
2019-04-21
linux mysql c++编程_Linux下进行MYSQL的C++编程起步手记
2019-04-21
Maria数据库怎么复制到mysql_MySQL、MariaDB数据库的AB复制配置过程
2019-04-21
mysql5.6 icp mrr bak_【mysql】关于ICP、MRR、BKA等特性
2019-04-21
mysql utf8跟utf8mb4_MySQL utf8 和 utf8mb4 的区别
2019-04-21
docker mysql开机自启动_Docker学习4-学会如何让容器开机自启服务【坑】
2019-04-21
在mysql中删除表正确的是什么_在MySQL中删除表的操作教程
2019-04-21
mysql有3个共同好友_共同好友mysql
2019-04-21
代理查询 mysql_查询数据库代理设置
2019-04-21
mysql dif_mysqldiff实现MySQL数据表比较
2019-04-21
mysql 允许其他主机访问权限_允许其他主机访问本机MySQL
2019-04-21
druid不能close mysql连接_alibaba druid mysql连接问题
2019-04-21
mysql 设置按天分表_MySQL 优化实战记录
2019-04-21
java连接mysql 不推荐_java连接mysql
2019-04-21