/[projects]/android/TrainInfo/src/dk/thoerup/traininfo/WelcomeScreen.java
ViewVC logotype

Contents of /android/TrainInfo/src/dk/thoerup/traininfo/WelcomeScreen.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 484 - (show annotations) (download)
Thu Oct 29 11:38:58 2009 UTC (14 years, 6 months ago) by torben
File size: 2116 byte(s)
Always read the application name from resource file (to ensure correct upper/lower case)
1 package dk.thoerup.traininfo;
2
3 import dk.thoerup.traininfo.util.MessageBox;
4 import android.app.Activity;
5 import android.content.Intent;
6 import android.os.Bundle;
7 import android.view.View;
8 import android.view.Window;
9 import android.view.View.OnClickListener;
10 import android.widget.Button;
11
12 public class WelcomeScreen extends Activity{
13 public enum ListType {
14 ListNearest,
15 ListSearch,
16 ListFavorites
17 }
18
19 @Override
20 public void onCreate(Bundle savedInstanceState) {
21 requestWindowFeature( Window.FEATURE_NO_TITLE );
22 super.onCreate(savedInstanceState);
23 setContentView(R.layout.welcome);
24
25 Button nearestButton = (Button) findViewById(R.id.nearest);
26 nearestButton.setOnClickListener( new StationListListener(ListType.ListNearest));
27
28 Button searchButton = (Button) findViewById(R.id.search);
29 searchButton.setOnClickListener( new StationListListener(ListType.ListSearch));
30
31 Button favoritesButton = (Button) findViewById(R.id.favorites);
32 favoritesButton.setOnClickListener( new StationListListener(ListType.ListFavorites));
33
34 Button aboutButton = (Button) findViewById(R.id.about);
35 aboutButton.setOnClickListener( new AboutListener() );
36 }
37
38 class AboutListener implements OnClickListener {
39
40 @Override
41 public void onClick(View v) {
42
43 String appName = WelcomeScreen.this.getResources().getString(R.string.app_name);
44 String ver = WelcomeScreen.this.getResources().getString(R.string.app_version);
45
46 StringBuffer message = new StringBuffer();
47 message.append(appName);
48 message.append(" v").append(ver).append("\n");
49 message.append("By Torben H. Nielsen\n");
50
51 MessageBox.showMessage(WelcomeScreen.this, message.toString());
52 }
53
54 }
55
56 class StationListListener implements OnClickListener{
57 ListType launchType;
58 StationListListener(ListType type) {
59 launchType = type;
60 }
61
62 @Override
63 public void onClick(View v) {
64 Intent intent = new Intent(WelcomeScreen.this, StationList.class);
65 intent.putExtra("type", launchType);
66 WelcomeScreen.this.startActivity(intent);
67 }
68
69 }
70 }

  ViewVC Help
Powered by ViewVC 1.1.20