options-menu

OptionMenu for whole App in Android?

此生再无相见时 提交于 2019-12-04 09:06:43
I can create an Option Menu for a single Activity. But now I want to create a Logout option in the menu which should be available on all Activities in the App. Is there a possible way to create an Option menu once for an Application? I answered this once on SO, but i forgot where...so here i go again. Its quite Straightforward. Create a BaseActivity (extends Activity ). Implement all your Options Menu Code in this. Override your onOptionsMenu ,etc... Now, For all your other Activities, instead of extending Activity, extend BaseActivity . You'll end up deriving all the options menu code...nifty

Android: onCreateOptionsMenu() item action

£可爱£侵袭症+ 提交于 2019-12-03 14:51:09
问题 I have a menu created through: @Override public boolean onCreateOptionsMenu(Menu menu) { menu.add("Email"); return super.onCreateOptionsMenu(menu); } But I can't remember how to set a onclicklistener so when its selected I can run my email function. 回答1: Override onOptionsItemSelected(MenuItem item) . So it would be like @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case 0: // do whatever return true; default: return super.onOptionsItemSelected

Android: onCreateOptionsMenu() item action

北城余情 提交于 2019-12-03 05:34:36
I have a menu created through: @Override public boolean onCreateOptionsMenu(Menu menu) { menu.add("Email"); return super.onCreateOptionsMenu(menu); } But I can't remember how to set a onclicklistener so when its selected I can run my email function. Override onOptionsItemSelected(MenuItem item) . So it would be like @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case 0: // do whatever return true; default: return super.onOptionsItemSelected(item); } } EDIT: Since this has gotten so many points, I should note that it is very good to add ID's to the

How to create an optionsMenu in an Android's TabActivity

↘锁芯ラ 提交于 2019-12-02 08:53:46
问题 I try to create options menu in a TabActivity. But instead of it I see for every activity within tabbar its own options menu. Is it possible change this behaviour? And if yes, how? Thank you 回答1: Ok. I think I know the solution. If there onCreateOptionsMenu in any activity within tabbar, so it should be modified a bit: @Override public boolean onCreateOptionsMenu(Menu menu) { // is activity withing a tabactivity if (getParent() != null) { return getParent().onCreateOptionsMenu(menu); } ... }

How to create an optionsMenu in an Android's TabActivity

瘦欲@ 提交于 2019-12-02 03:58:41
I try to create options menu in a TabActivity. But instead of it I see for every activity within tabbar its own options menu. Is it possible change this behaviour? And if yes, how? Thank you Ok. I think I know the solution. If there onCreateOptionsMenu in any activity within tabbar, so it should be modified a bit: @Override public boolean onCreateOptionsMenu(Menu menu) { // is activity withing a tabactivity if (getParent() != null) { return getParent().onCreateOptionsMenu(menu); } ... } 来源: https://stackoverflow.com/questions/5102662/how-to-create-an-optionsmenu-in-an-androids-tabactivity

WebView Back, Refresh, Forward? Simply doesn't work!

人走茶凉 提交于 2019-11-30 20:53:16
I have tried everything to get my 'forward' and 'back' to work. Refresh is working [I figured it out by changing the method to read 'webView.reload();' instead of 'webView.refresh();' Can anyone assist with the forward and back? I have tried 'forward', 'canGoForward' and 'goForward' as well as 'back', 'canGoBack' and 'goBack'. There are no error codes however none of those methods actually do anything. public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); // Add menu items, second value is the id, use this in the onCreateOptionsMenu menu.add(0, 1, 0, "Back"); menu

WebView Back, Refresh, Forward? Simply doesn't work!

空扰寡人 提交于 2019-11-30 04:49:43
问题 I have tried everything to get my 'forward' and 'back' to work. Refresh is working [I figured it out by changing the method to read 'webView.reload();' instead of 'webView.refresh();' Can anyone assist with the forward and back? I have tried 'forward', 'canGoForward' and 'goForward' as well as 'back', 'canGoBack' and 'goBack'. There are no error codes however none of those methods actually do anything. public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); // Add

“No keyboard for id 0” - what does it mean?

旧时模样 提交于 2019-11-29 02:14:14
Each time my Optionsmenu opens (onCreateOptionsMenu(..) is called), I get these warnings: "No keyboard for id 0" and "Using default keyMap: /system/usr/keychars/qwerty.kcm.bin" I couldn't find out what they mean, does anyone know ? I didn't like this answer . Here's the simple code I'm using: @Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); getMenuInflater().inflate(R.menu.optmenu_start, menu); return true; } and the optmenu_start.xml: <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/optmenu_prefs" android:title=

How can I alter a MenuItem on the Options Menu on Android?

安稳与你 提交于 2019-11-28 04:51:50
I have an Options Menu on my Activity with an MenuItem "Start". When this MenuItem is selected I would like to alter the Menu so it contains a MenuItem "Stop". And finally when "Stop" is selected, I would like to alter back to "Start". Here is parts of my code that isn't working. I have both "Start" and "Stop" listed in mymenu.xml I should probably remove "stop" when the menu is created: public class MyActivity extends Activity { private boolean isStarted = false; @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); menu.removeItem(R.id.stop);

java.lang.illegalstateexception: a factory has already been set on this layoutinflater

自闭症网瘾萝莉.ら 提交于 2019-11-27 23:52:44
I have tried to change the background color of options menu in my android app. I am using ActionBarSherlock library. I have tried this code for changing the background color of options menu https://stackoverflow.com/a/8475357/584095 But I ended up with an exception "java.lang.illegalstateexception: a factory has already been set on this layoutinflater" at line LayoutInflater.setFactory(); I don't know what is wrong in this code. Can anyone help me in resolving this issue? There been a change in support library since version 22.1.0. You will get an IllegalStateException if you try to call