Developing MyQuiz Apps Part 2
Using ADT 18 On Win 7
http://android-steps.blogspot.com/2014/12/developing-myquiz-android-apps-part-1.html
or download startup file
https://drive.google.com/file/d/0B86b-ALn-1MGY0NUVWM3dVUwYUk/view?usp=sharing
Replace the content of splash layout file as follows.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/bckgrnd"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/logo" /> </RelativeLayout> |
File name: MyQuiz/res/layout/splash.xml
You can simulate the landscape view by clicking the orientation button. |
package com.example.myquiz; import android.os.Bundle; public class QuizSplashActivity extends QuizActivity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.splash); new Handler().postDelayed(new Runnable() { @Override public void run() { // This method will be executed once the timer is over // Start QuizMenuActivity Intent i = new Intent(QuizSplashActivity.this, QuizMenuActivity.class); startActivity(i);
// close this activity finish(); } }, 3000); //3000 milliseconds } } |
You have to import the following classes… import android.content.Intent; import android.os.Handler; |
Read more about handler and postDelayed here, http://developer.android.com/reference/android/os/Handler.html#postDelayed(java.lang.Runnable, long) |
Make sure that the activity QuizMenuActivity is added into Android Manifest.
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.myquiz" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="18" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="com.example.myquiz.QuizSplashActivity" 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="QuizMenuActivity"> </activity> </application> </manifest> |
1) http://developer.android.com/reference/android/os/Handler.html
2) http://www.androidhive.info/2013/07/how-to-implement-android-splash-screen-2/
https://drive.google.com/file/d/0B86b-ALn-1MGdDc1N0xfNDlQYmc/view?usp=sharing