Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public boolean onCreateOptionsMenu(com.actionbarsherlock.view.Menu menu) {
- getSupportMenuInflater().inflate(R.menu.main, menu);
- return true;
- }
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- return false;
- }
- @Override
- public boolean onPrepareOptionsMenu(Menu menu) {
- MenuItem item= menu.findItem(R.id.action_settings);
- item.setVisible(false);
- return true;
- }
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- return false;
- }
- <item
- android:id="@+id/action_settings"
- android:orderInCategory="100"
- android:showAsAction="never"
- android:title="@string/action_settings"/>
- @Override
- public void onCreate(Bundle savedInstanceState) {
- getApplicationInfo().targetSdkVersion = 10; // To enable the 3-dot menu call this code before super.OnCreate
- super.onCreate(savedInstanceState);
- }
- @Override
- public void onCreate(Bundle savedInstanceState) {
- getApplicationInfo().targetSdkVersion = 14; // To disable the 3-dot menu call this code before super.OnCreate
- super.onCreate(savedInstanceState);
- }
- @Override
- public boolean onCreateOptionsMenu(Menu menu)
- {
- //Inflate the menu; this adds items to the action bar if it is present.
- getMenuInflater().inflate(R.menu.menu_planos, menu);
- return true;
- }
- <item
- android:id="@+id/action_settings"
- android:orderInCategory="100"
- android:showAsAction="never"
- visibility=false
- android:title="@string/action_settings"/>
- <item
- android:id="@+id/linearlayout_splash"
- android:orderInCategory="100"
- android:showAsAction="never"
- android:visible="false"
- android:title="@string/action_settings"/>
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- // Inflate the menu; this adds items to the action bar if it is present.
- getMenuInflater().inflate(R.menu.main, menu);
- return true;
- }
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- // Handle action bar item clicks here. The action bar will
- // automatically handle clicks on the Home/Up button, so long
- // as you specify a parent activity in AndroidManifest.xml.
- int id = item.getItemId();
- //noinspection SimplifiableIfStatement
- if (id == R.id.action_settings) {
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
- Menu overflow;
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.mymenu, menu);
- this.overflow = menu;
- return super.onCreateOptionsMenu(menu);
- }
- public void hideorShowMenuItems(boolean bool){
- overflow.getItem(1).setVisible(bool);
- overflow.getItem(2).setVisible(bool);
- overflow.getItem(3).setVisible(bool);
- overflow.getItem(4).setVisible(bool);
- overflow.getItem(5).setVisible(bool);
- }
- <?xml version="1.0" encoding="utf-8"?>
- <menu xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto">
- <item
- android:id="@+id/action_settings"
- android:orderInCategory="100"
- android:visible="false"
- android:title="@string/action_settings"
- app:showAsAction="never" />
- </menu>
- @Override
- public boolean onPrepareOptionsMenu(Menu menu) {
- // if nav drawer is opened, hide the action items
- boolean drawerOpen = mDrawerLayout.isDrawerOpen(leftDrawer);
- return (!drawerOpen);
- }
- @Override
- public boolean onKeyDown(int keycode, KeyEvent event ) {
- //KEYCODE_MENU
- if(keycode == KeyEvent.KEYCODE_MENU){
- /* AlertDialog.Builder dialogBuilder
- = new AlertDialog.Builder(this)
- .setMessage("Test")
- .setTitle("Menu dialog");
- dialogBuilder.create().show();*/
- return true;
- // finish();
- }
- return super.onKeyDown(keycode,event);
- }
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.main, menu);
- return true;
- }
- <menu xmlns:android="http://schemas.android.com/apk/res/android" ></menu>
- <style name="AppTheme" parent="Theme.AppCompat.Light">
- ...
- <item name="android:actionOverflowButtonStyle">@style/AppTheme.Overflow</item>
- <!-- If you're using AppCompat, instead use -->
- <item name="actionOverflowButtonStyle">@style/AppTheme.Overflow</item>
- </style>
- <style name="AppTheme" />
- <style name="AppTheme.Overflow">
- <item name="android:src">@null</item>
- </style>
- <activity android:name=".NoOverflowActivity"
- android:theme="@style/AppTheme.NoOverflow" >
- for hiding 3 dots in actionbar/ toolbar
- public boolean onCreateOptionsMenu(Menu menu) {
- // Inflate the menu; this adds items to the action bar if it is present.
- getMenuInflater().inflate(R.menu.activity_dash_board_drawer, menu);
- return false; //for visible 3 dots change to true, hiding false
- }
Add Comment
Please, Sign In to add comment