Commits

Luke Plant committed 04121f6

Added basic menu.

Comments (0)

Files changed (3)

gen/net/learnscripture/webviewapp/R.java

         public static final int ic_launcher=0x7f020000;
     }
     public static final class id {
-        public static final int fullscreen_content_controls=0x7f070000;
-        public static final int progressbar=0x7f070001;
-        public static final int web_engine=0x7f070002;
+        public static final int dashboard_menuitem=0x7f080003;
+        public static final int fullscreen_content_controls=0x7f080000;
+        public static final int progressbar=0x7f080001;
+        public static final int refresh_menuitem=0x7f080004;
+        public static final int web_engine=0x7f080002;
     }
     public static final class layout {
         public static final int activity_dashboard=0x7f030000;
     }
+    public static final class menu {
+        public static final int main_menu=0x7f070000;
+    }
     public static final class string {
         public static final int app_name=0x7f050000;
     }

res/menu/main_menu.xml

+<?xml version="1.0" encoding="utf-8"?>
+<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+    <item android:id="@+id/dashboard_menuitem" android:title="Dashboard"></item>
+    <item android:id="@+id/refresh_menuitem" android:title="Refresh"></item>
+    
+
+</menu>

src/net/learnscripture/webviewapp/Dashboard.java

 import android.app.Activity;
 import android.graphics.Bitmap;
 import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
 import android.view.View;
 import android.view.WindowManager;
 import android.webkit.WebChromeClient;
 		engine.loadUrl("http://learnscripture.net/");
 	}
 
+	private WebView getEngine() {
+		return (WebView) findViewById(R.id.web_engine);
+	}
+
 	public void onBackPressed() {
-		WebView engine = (WebView) findViewById(R.id.web_engine);
+		WebView engine = getEngine();
 		String url = engine.getUrl(); 
 		if (url.equals("http://learnscripture.net/") ||
 				url.equals("http://learnscripture.net/dashboard/") ||
 		}
 	}
 
+	@Override
+	public boolean onCreateOptionsMenu(Menu menu) {
+		MenuInflater inflater = getMenuInflater();
+		inflater.inflate(R.menu.main_menu, menu);
+		return true;
+	}
+
+	@Override
+	public boolean onOptionsItemSelected(MenuItem item) {
+		// Handle item selection
+		switch (item.getItemId()) {
+		case R.id.dashboard_menuitem:
+			getEngine().loadUrl("http://learnscripture.net/dashboard/");
+			return true;
+		case R.id.refresh_menuitem:
+			getEngine().reload();
+			return true;
+		default:
+			return super.onOptionsItemSelected(item);
+		}
+	}
+
 	private class FixedWebViewClient extends WebViewClient {
 		@Override
 		public boolean shouldOverrideUrlLoading(WebView view, String url) {