Permalink
Browse files

clean up main menu screen.

  • Loading branch information...
1 parent ce5a736 commit 45ef47e9f60d62cafd89f0a02d8c9bd1891f7e67 @gregkh committed Jun 9, 2010
Showing with 23 additions and 44 deletions.
  1. +6 −5 res/layout/main.xml
  2. +1 −1 res/values/strings.xml
  3. +16 −38 src/com/kroah/clock/Clock.java
View
@@ -9,9 +9,10 @@
android:layout_height="wrap_content"
android:text="@string/hello"
/>
- <ListView
- android:id="@+id/myListView"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- />
+ <Button
+ android:id="@+id/myButton"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/ok"
+ />
</LinearLayout>
View
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
- <string name="hello">List of watched timezones here?</string>
+ <string name="hello"> This is a Widget, so there is nothing to do here</string>
<string name="app_name">World Clock</string>
<string name="app_descrip">A World Clock desktop widget</string>
<string name="ok">Ok</string>
@@ -1,13 +1,12 @@
package com.kroah.clock;
-import java.util.ArrayList;
-
import android.app.Activity;
import android.os.Bundle;
+import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
-import android.widget.ArrayAdapter;
-import android.widget.ListView;
+import android.view.View;
+import android.widget.Button;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
@@ -16,6 +15,8 @@
public class Clock extends Activity {
+ public static final String MODULE = "GREGKHMainScreen";
+
// Display a simple "About" dialog
final void about() {
AlertDialog.Builder ad = new AlertDialog.Builder(Clock.this);
@@ -36,15 +37,11 @@ public void onCancel(DialogInterface Dialog) {
ad.show();
}
- static final private int MENU_ADD = 0;
- static final private int MENU_SETTINGS = 1;
- static final private int MENU_ABOUT = 2;
- static final private int MENU_EXIT = 3;
+ static final private int MENU_ABOUT = 0;
+ static final private int MENU_EXIT = 1;
/* Creates the menu items */
public boolean onCreateOptionsMenu(Menu menu) {
- menu.add(0, MENU_ADD, 0, "Add").setIcon(R.drawable.menu_add);
- menu.add(0, MENU_SETTINGS, 0, "Settings").setIcon(R.drawable.menu_preferences);
menu.add(0, MENU_ABOUT, 0, "About").setIcon(R.drawable.menu_about);
menu.add(0, MENU_EXIT, 0, "Exit").setIcon(R.drawable.menu_close);
return true;
@@ -53,13 +50,6 @@ public boolean onCreateOptionsMenu(Menu menu) {
/* Handles item selections */
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
- case MENU_ADD:
- timezone_list.add(0, "timezone foo");
- timezone_adapter.notifyDataSetChanged();
- return true;
- case MENU_SETTINGS:
- //settings();
- return true;
case MENU_ABOUT:
about();
return true;
@@ -70,32 +60,20 @@ public boolean onOptionsItemSelected(MenuItem item) {
return false;
}
- private ArrayList<String> timezone_list;
- private ArrayAdapter<String> timezone_adapter;
-
+ private Button okButton;
+
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
- ListView myListView = (ListView)findViewById(R.id.myListView);
-
- timezone_list = new ArrayList<String>();
- timezone_adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, timezone_list);
- myListView.setAdapter(timezone_adapter);
-
- timezone_list.add(0, "timezone 1");
- timezone_list.add(0, "timezone 2");
- timezone_list.add(0, "timezone 3");
- timezone_list.add(0, "timezone 4");
- timezone_list.add(0, "timezone 5");
- timezone_list.add(0, "timezone 6");
- timezone_list.add(0, "timezone 7");
- timezone_list.add(0, "timezone 8");
- timezone_list.add(0, "timezone 9");
- timezone_list.add(0, "timezone10");
- timezone_list.add(0, "timezone22");
- timezone_adapter.notifyDataSetChanged();
+ okButton = (Button)findViewById(R.id.myButton);
+ okButton.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ Log.d(MODULE, "button clicked");
+ finish();
+ }
+ });
}
}

0 comments on commit 45ef47e

Please sign in to comment.