Guest User

Untitled

a guest
Dec 15th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.69 KB | None | 0 0
  1. @Override
  2. public boolean onCreateOptionsMenu(com.actionbarsherlock.view.Menu menu) {
  3. getSupportMenuInflater().inflate(R.menu.main, menu);
  4. return true;
  5. }
  6.  
  7. @Override
  8. public boolean onCreateOptionsMenu(Menu menu) {
  9. return false;
  10. }
  11.  
  12. @Override
  13. public boolean onPrepareOptionsMenu(Menu menu) {
  14. MenuItem item= menu.findItem(R.id.action_settings);
  15. item.setVisible(false);
  16. return true;
  17. }
  18.  
  19. @Override
  20. public boolean onCreateOptionsMenu(Menu menu) {
  21. return false;
  22. }
  23.  
  24. <item
  25. android:id="@+id/action_settings"
  26. android:orderInCategory="100"
  27. android:showAsAction="never"
  28. android:title="@string/action_settings"/>
  29.  
  30. @Override
  31. public void onCreate(Bundle savedInstanceState) {
  32. getApplicationInfo().targetSdkVersion = 10; // To enable the 3-dot menu call this code before super.OnCreate
  33. super.onCreate(savedInstanceState);
  34. }
  35.  
  36. @Override
  37. public void onCreate(Bundle savedInstanceState) {
  38. getApplicationInfo().targetSdkVersion = 14; // To disable the 3-dot menu call this code before super.OnCreate
  39. super.onCreate(savedInstanceState);
  40. }
  41.  
  42. @Override
  43. public boolean onCreateOptionsMenu(Menu menu)
  44. {
  45. //Inflate the menu; this adds items to the action bar if it is present.
  46. getMenuInflater().inflate(R.menu.menu_planos, menu);
  47. return true;
  48. }
  49.  
  50. <item
  51. android:id="@+id/action_settings"
  52. android:orderInCategory="100"
  53. android:showAsAction="never"
  54. visibility=false
  55. android:title="@string/action_settings"/>
  56.  
  57. <item
  58. android:id="@+id/linearlayout_splash"
  59. android:orderInCategory="100"
  60. android:showAsAction="never"
  61. android:visible="false"
  62. android:title="@string/action_settings"/>
  63.  
  64. @Override
  65. public boolean onCreateOptionsMenu(Menu menu) {
  66. // Inflate the menu; this adds items to the action bar if it is present.
  67. getMenuInflater().inflate(R.menu.main, menu);
  68. return true;
  69. }
  70.  
  71. @Override
  72. public boolean onOptionsItemSelected(MenuItem item) {
  73. // Handle action bar item clicks here. The action bar will
  74. // automatically handle clicks on the Home/Up button, so long
  75. // as you specify a parent activity in AndroidManifest.xml.
  76. int id = item.getItemId();
  77.  
  78. //noinspection SimplifiableIfStatement
  79. if (id == R.id.action_settings) {
  80. return true;
  81. }
  82.  
  83. return super.onOptionsItemSelected(item);
  84. }
  85.  
  86. Menu overflow;
  87.  
  88. @Override
  89. public boolean onCreateOptionsMenu(Menu menu) {
  90.  
  91. getMenuInflater().inflate(R.menu.mymenu, menu);
  92. this.overflow = menu;
  93. return super.onCreateOptionsMenu(menu);
  94. }
  95.  
  96. public void hideorShowMenuItems(boolean bool){
  97. overflow.getItem(1).setVisible(bool);
  98. overflow.getItem(2).setVisible(bool);
  99. overflow.getItem(3).setVisible(bool);
  100. overflow.getItem(4).setVisible(bool);
  101. overflow.getItem(5).setVisible(bool);
  102. }
  103.  
  104. <?xml version="1.0" encoding="utf-8"?>
  105. <menu xmlns:android="http://schemas.android.com/apk/res/android"
  106. xmlns:app="http://schemas.android.com/apk/res-auto">
  107. <item
  108. android:id="@+id/action_settings"
  109. android:orderInCategory="100"
  110. android:visible="false"
  111. android:title="@string/action_settings"
  112. app:showAsAction="never" />
  113. </menu>
  114.  
  115. @Override
  116. public boolean onPrepareOptionsMenu(Menu menu) {
  117. // if nav drawer is opened, hide the action items
  118. boolean drawerOpen = mDrawerLayout.isDrawerOpen(leftDrawer);
  119. return (!drawerOpen);
  120. }
  121.  
  122. @Override
  123. public boolean onKeyDown(int keycode, KeyEvent event ) {
  124. //KEYCODE_MENU
  125. if(keycode == KeyEvent.KEYCODE_MENU){
  126. /* AlertDialog.Builder dialogBuilder
  127. = new AlertDialog.Builder(this)
  128. .setMessage("Test")
  129. .setTitle("Menu dialog");
  130. dialogBuilder.create().show();*/
  131. return true;
  132.  
  133. // finish();
  134. }
  135. return super.onKeyDown(keycode,event);
  136. }
  137.  
  138. @Override
  139. public boolean onCreateOptionsMenu(Menu menu) {
  140. getMenuInflater().inflate(R.menu.main, menu);
  141. return true;
  142. }
  143.  
  144. <menu xmlns:android="http://schemas.android.com/apk/res/android" ></menu>
  145.  
  146. <style name="AppTheme" parent="Theme.AppCompat.Light">
  147. ...
  148. <item name="android:actionOverflowButtonStyle">@style/AppTheme.Overflow</item>
  149. <!-- If you're using AppCompat, instead use -->
  150. <item name="actionOverflowButtonStyle">@style/AppTheme.Overflow</item>
  151. </style>
  152.  
  153. <style name="AppTheme" />
  154. <style name="AppTheme.Overflow">
  155. <item name="android:src">@null</item>
  156. </style>
  157.  
  158. <activity android:name=".NoOverflowActivity"
  159. android:theme="@style/AppTheme.NoOverflow" >
  160.  
  161. for hiding 3 dots in actionbar/ toolbar
  162.  
  163. public boolean onCreateOptionsMenu(Menu menu) {
  164. // Inflate the menu; this adds items to the action bar if it is present.
  165. getMenuInflater().inflate(R.menu.activity_dash_board_drawer, menu);
  166. return false; //for visible 3 dots change to true, hiding false
  167. }
Add Comment
Please, Sign In to add comment