Skip to content

Commit

Permalink
clean up main menu screen.
Browse files Browse the repository at this point in the history
  • Loading branch information
gregkh committed Jun 9, 2010
1 parent ce5a736 commit 45ef47e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 44 deletions.
11 changes: 6 additions & 5 deletions res/layout/main.xml
Expand Up @@ -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>
2 changes: 1 addition & 1 deletion res/values/strings.xml
@@ -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>
Expand Down
54 changes: 16 additions & 38 deletions src/com/kroah/clock/Clock.java
@@ -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;
Expand All @@ -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);
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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.