android in practice_Displaying splash screens with timers(MyMovies project)
来源:互联网 发布:java正则匹配时间格式 编辑:程序博客网 时间:2024/06/06 05:08
You want to execute a delayed task that executes its logic only after a certain amount of time has passed.
The splash image can be dropped in the res/drawables folder:splash.png
The layout for a splash screen Activity:splash_screen.xml:
<?xml version="1.0" encoding="utf-8"?><merge xmlns:android="http://schemas.android.com/apk/res/android"> <ImageView android:layout_width="fill_parent" android:layout_height="fill_parent" android:scaleType="fitXY" android:src="@drawable/splash" /></merge>We also need to define the new Activity in the manifest file. Because it’ll be the first Activity that’s launched, it’ll take the place of the MyMovies Activity.
......... <activity android:name=".SplashScreen" android:label="@string/title_myMovie" android:theme="@style/SplashScreen"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".MyMovies" />.........
We want the splash screen to be fullscreen, so add the following code to your styles.xml:
<style name="SplashScreen" parent="@android:style/Theme.Black"><item name="android:windowNoTitle">true</item></style>
create the activity class SplashScreen
public class SplashScreen extends Activity { public static final int SPLASH_TIMEOUT = 2000; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.splash_screen); new Timer().schedule(new TimerTask(){@Overridepublic void run() {// TODO Auto-generated method stubproceed();} }, SPLASH_TIMEOUT); } public boolean onTouchEvent(MotionEvent event){ if(event.getAction()==MotionEvent.ACTION_DOWN){ proceed(); } return super.onTouchEvent(event); } private void proceed() { if(this.isFinishing()){ return; } startActivity(new Intent(SplashScreen.this,MyMovies.class)); finish(); }}
The task itself creates an Intent to launch our landing screen (the MyMovies main Activity).
- android in practice_Displaying splash screens with timers(MyMovies project)
- android in practice_Implementing jobs with AsyncTask(MyMovies project)
- android in practice_Managing threads in thread pools(MyMovies project)
- android in practice_Preparing for configuration changes(MyMovies project)
- 启动画面(Splash Screens)
- 启动画面(Splash Screens)
- HANDLING JAVASCRIPT IN SCRAPY WITH SPLASH
- android-Supporting Different Screens in Web Apps
- android in practice_Communicating with a Service (portfolio project)
- 3-8 启动画面(Splash Screens)
- 第二章 第六节 绘制Splash Screens
- (转)3.8启动画面(Splash Screens)
- Splash Screens - 启动页面设置
- A guide to using Paneled Forms, Multi-Splash Screens, SQL Express, and many more in Windows Application Development
- Android Studio project with path '... ' could not be found in project ' app' 报错解决方案
- Android API Guides---Supporting Different Screens in Web Apps
- Different timers in .net
- STM32F4 PWM tutorial with TIMERs
- Java Web Application 自架构 五 AOP概念的引入
- 辛苦的2013年
- 软件项目管理系统-项目管理-模块定义-开发笔记
- C++小时钟(包含C++类继承, C++ IO, 定时器)
- 工控软件开发
- android in practice_Displaying splash screens with timers(MyMovies project)
- 菜鸟黑客的第一天——一些基础的手法
- Python字符编码详解
- Nginx实现负载均衡
- 一个欧几里得扩展的应用
- linux配置IP
- linux内核中的文件描述符(一)--基础知识简介
- 公元二零一三之个人读书计划
- Codeforces Beta Round #93 (Div. 2 Only)——B