Joe Michail
- Forum posts: 1
Apr 11, 2013, 1:29:22 AM via Website
Apr 11, 2013 1:29:22 AM via Website
Hi, I'm working through the Sams Teach Yourself Android Development and I'm trying to switch my splash screen to a secondary screen. I put the code in my first screen and made sure the manifest style had the secondary screen. Can someone tell me why this isn't working?
Splash screen code:
My secondary screen
My Manifest File
Thanks
Splash screen code:
1package com.androidbook.triviaquiz;
2
3
4import android.content.Intent;
5import android.os.Bundle;
6import android.os.Handler;
7import android.view.animation.Animation;
8import android.view.animation.AnimationUtils;
9import android.view.animation.LayoutAnimationController;
10import android.widget.TableLayout;
11import android.widget.TableRow;
12import android.widget.TextView;
13
14public class QuizSplashActivity extends QuizActivity {
15
16
17 @Override
18 protected void onCreate(Bundle savedInstanceState) {
19 super.onCreate(savedInstanceState);
20 setContentView(R.layout.splash);
21
22 TextView logo1 = (TextView) findViewById(R.id.TextViewTopTitle);
23 Animation fade1 = AnimationUtils.loadAnimation(this, R.anim.fade_in);
24 logo1.startAnimation(fade1);
25
26 TextView logo2 = (TextView) findViewById(R.id.BottomView1);
27 Animation fade2 = AnimationUtils.loadAnimation(this, R.anim.fade_in);
28 logo2.startAnimation(fade2);
29
30 Animation spinin= AnimationUtils.loadAnimation(this, R.anim.custom_anim);
31 new LayoutAnimationController(spinin);
32 TableLayout table = (TableLayout) findViewById(R.id.TableLayout01); {
33 for (int i = 0; i < table.getChildCount(); i++) {
34 TableRow row = (TableRow) table.getChildAt(i);
35 row.clearAnimation();
36
37
38
39
40 new Handler().postDelayed(new Runnable() {
41 public void run() {
42
43 TextView logo1=(TextView) findViewById(R.id.TextViewTopTitle);
44 logo1.clearAnimation();
45 TextView logo2=(TextView) findViewById(R.id.BottomView1);
46 logo2.clearAnimation();
47
48 startActivity(new Intent(QuizSplashActivity.this, QuizMenuActivity.class));
49 QuizSplashActivity.this.finish();
50
51 }}, fade2.getDuration());
52
53 };
54 }
55 }
56
57
58
59
60
61 @Override
62 protected void onPause() {
63 super.onPause();
64 TextView logo1= (TextView) findViewById(R.id.TextViewTopTitle);
65 logo1.clearAnimation();
66 TextView logo2= (TextView) findViewById(R.id.BottomView1);
67 logo2.clearAnimation();
68 }
69 }
2
3
4import android.content.Intent;
5import android.os.Bundle;
6import android.os.Handler;
7import android.view.animation.Animation;
8import android.view.animation.AnimationUtils;
9import android.view.animation.LayoutAnimationController;
10import android.widget.TableLayout;
11import android.widget.TableRow;
12import android.widget.TextView;
13
14public class QuizSplashActivity extends QuizActivity {
15
16
17 @Override
18 protected void onCreate(Bundle savedInstanceState) {
19 super.onCreate(savedInstanceState);
20 setContentView(R.layout.splash);
21
22 TextView logo1 = (TextView) findViewById(R.id.TextViewTopTitle);
23 Animation fade1 = AnimationUtils.loadAnimation(this, R.anim.fade_in);
24 logo1.startAnimation(fade1);
25
26 TextView logo2 = (TextView) findViewById(R.id.BottomView1);
27 Animation fade2 = AnimationUtils.loadAnimation(this, R.anim.fade_in);
28 logo2.startAnimation(fade2);
29
30 Animation spinin= AnimationUtils.loadAnimation(this, R.anim.custom_anim);
31 new LayoutAnimationController(spinin);
32 TableLayout table = (TableLayout) findViewById(R.id.TableLayout01); {
33 for (int i = 0; i < table.getChildCount(); i++) {
34 TableRow row = (TableRow) table.getChildAt(i);
35 row.clearAnimation();
36
37
38
39
40 new Handler().postDelayed(new Runnable() {
41 public void run() {
42
43 TextView logo1=(TextView) findViewById(R.id.TextViewTopTitle);
44 logo1.clearAnimation();
45 TextView logo2=(TextView) findViewById(R.id.BottomView1);
46 logo2.clearAnimation();
47
48 startActivity(new Intent(QuizSplashActivity.this, QuizMenuActivity.class));
49 QuizSplashActivity.this.finish();
50
51 }}, fade2.getDuration());
52
53 };
54 }
55 }
56
57
58
59
60
61 @Override
62 protected void onPause() {
63 super.onPause();
64 TextView logo1= (TextView) findViewById(R.id.TextViewTopTitle);
65 logo1.clearAnimation();
66 TextView logo2= (TextView) findViewById(R.id.BottomView1);
67 logo2.clearAnimation();
68 }
69 }
My secondary screen
1package com.androidbook.triviaquiz;
2
3import android.os.Bundle;
4import android.widget.ArrayAdapter;
5import android.widget.ListView;
6
7public class QuizMenuActivity extends QuizActivity {
8
9
10 @Override
11 protected void onCreate(Bundle savedInstanceState) {
12 super.onCreate(savedInstanceState);
13 setContentView(R.layout.menu);
14
15 ListView menuList = (ListView) findViewById(R.id.listView1);
16 String[] items = { getResources().getString(R.string.itemplay),
17 getResources().getString(R.string.itemscores),
18 getResources().getString(R.string.itemsettings),
19 getResources().getString(R.string.itemhelp) };
20 ArrayAdapter<String> adapt = new ArrayAdapter<String>(this, R.layout.menuitem, items);
21 menuList.setAdapter(adapt);
22
23
24 }
25
26
27}
2
3import android.os.Bundle;
4import android.widget.ArrayAdapter;
5import android.widget.ListView;
6
7public class QuizMenuActivity extends QuizActivity {
8
9
10 @Override
11 protected void onCreate(Bundle savedInstanceState) {
12 super.onCreate(savedInstanceState);
13 setContentView(R.layout.menu);
14
15 ListView menuList = (ListView) findViewById(R.id.listView1);
16 String[] items = { getResources().getString(R.string.itemplay),
17 getResources().getString(R.string.itemscores),
18 getResources().getString(R.string.itemsettings),
19 getResources().getString(R.string.itemhelp) };
20 ArrayAdapter<String> adapt = new ArrayAdapter<String>(this, R.layout.menuitem, items);
21 menuList.setAdapter(adapt);
22
23
24 }
25
26
27}
My Manifest File
1<?xml version="1.0" encoding="utf-8"?>
2<manifest
3 package="com.androidbook.triviaquiz"
4 android:versionCode="1"
5 android:versionName="1.0" >
6
7 <uses-sdk
8 android:minSdkVersion="7"
9 android:targetSdkVersion="7" />
10
11 <application
12 android:allowBackup="true"
13 android:icon="@drawable/quizicon"
14 android:label="@string/app_name"
15 android:theme="@style/AppTheme" >
16 <activity
17 android:name="com.androidbook.triviaquiz.QuizSplashActivity"
18
19 android:label="@string/app_name" >
20
21
22
23 <intent-filter>
24 <action android:name="android.intent.action.MAIN" />
25
26 <category android:name="android.intent.category.LAUNCHER" />
27 </intent-filter>
28 </activity>
29 <activity
30 android:name=".QuizMenuActivity" >
31 </activity>
32 </application>
33
34</manifest>
2<manifest
3 package="com.androidbook.triviaquiz"
4 android:versionCode="1"
5 android:versionName="1.0" >
6
7 <uses-sdk
8 android:minSdkVersion="7"
9 android:targetSdkVersion="7" />
10
11 <application
12 android:allowBackup="true"
13 android:icon="@drawable/quizicon"
14 android:label="@string/app_name"
15 android:theme="@style/AppTheme" >
16 <activity
17 android:name="com.androidbook.triviaquiz.QuizSplashActivity"
18
19 android:label="@string/app_name" >
20
21
22
23 <intent-filter>
24 <action android:name="android.intent.action.MAIN" />
25
26 <category android:name="android.intent.category.LAUNCHER" />
27 </intent-filter>
28 </activity>
29 <activity
30 android:name=".QuizMenuActivity" >
31 </activity>
32 </application>
33
34</manifest>
Thanks
Recommended editorial content
With your consent, external content is loaded here.
By clicking on the button above, you agree that external content may be displayed to you. Personal data may be transmitted to third-party providers in the process. You can find more information about this in our Privacy Policy.