AIDE Tutorial -27 Splash Screen
Add new xml:Splash.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:gravity="center">
<TextView
android:text="Welcome to my app"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
Add new java: Splash.java
Add new xml:Splash.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:gravity="center">
<TextView
android:text="Welcome to my app"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
Add new java: Splash.java
package com.kc.splashscreen;
import android.app.*;
import android.os.*;
import java.util.*;
import android.content.*;
import android.app.*;
import android.os.*;
import java.util.*;
import android.content.*;
public class splash extends Activity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
Timer time=new Timer();
time.schedule(new TimerTask(){
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
Timer time=new Timer();
time.schedule(new TimerTask(){
@Override
public void run()
{
// TODO: Implement this method
Intent in=new Intent(splash.this,MainActivity.class);
startActivity(in);
finish();
}},3000);}}
Android Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.kc.splashscreen" >
public void run()
{
// TODO: Implement this method
Intent in=new Intent(splash.this,MainActivity.class);
startActivity(in);
finish();
}},3000);}}
Android Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.kc.splashscreen" >
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".splash"
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"/>
</application>
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".splash"
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"/>
</application>
</manifest>
Tanginamo ayaw nmn ma copy
ReplyDelete