From: Eugene Crosser Date: Mon, 30 Jan 2012 12:32:16 +0000 (+0400) Subject: add options menu X-Git-Url: http://average.org/gitweb/?a=commitdiff_plain;h=f8ce18fab68dccae08e0897d2f9acf647ccba09c;p=WhereAmI.git add options menu --- diff --git a/res/menu/main_menu.xml b/res/menu/main_menu.xml new file mode 100644 index 0000000..6fd0da1 --- /dev/null +++ b/res/menu/main_menu.xml @@ -0,0 +1,9 @@ + + + + + diff --git a/res/values/strings.xml b/res/values/strings.xml index d321d3c..91ad670 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -5,6 +5,8 @@ Неудача Последнее обновление Неудачная попытка + Выход + Конфигурация января февраля diff --git a/src/org/average/whereami/WhereAmI.java b/src/org/average/whereami/WhereAmI.java index 988f1fb..2323f54 100644 --- a/src/org/average/whereami/WhereAmI.java +++ b/src/org/average/whereami/WhereAmI.java @@ -16,6 +16,9 @@ import android.content.res.Resources; import android.text.format.Time; import android.util.Log; import android.view.View; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; import android.view.Window; import android.view.WindowManager; import android.widget.TextView; @@ -217,4 +220,27 @@ public class WhereAmI extends Activity boolean wifion = wifiman.setWifiEnabled(false); Log.w("WhereAmI", "disabling wifi result " + wifion); } + + /** Called when the menu is activated. */ + @Override + public boolean onCreateOptionsMenu(Menu menu) { + MenuInflater inflater = getMenuInflater(); + inflater.inflate(R.menu.main_menu, menu); + return true; + } + + /** Called when the menu item is selected */ + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case R.id.quit: + finish(); + return true; + case R.id.settings: + Log.w("WhereAmI", "settings requested"); + return true; + default: + return super.onOptionsItemSelected(item); + } + } }