Android adding a submenu to a menuItem, where is addSubMenu()?

Sometimes Android weirdness is really amazing (and amusing..). I solved it this way: a) Define in XML a submenu placeholder like this: <item android:visible=”true” android:id=”@+id/m_area” android:titleCondensed=”Areas” android:title=”Areas” android:icon=”@drawable/restaur” android:enabled=”true”> <menu> <item android:id=”@+id/item1″ android:title=”Placeholder”></item> </menu> </item> b) Get sub menu item in OnCreateOptionsMenu, clear it and add my submenu items, like this: public boolean onCreateOptionsMenu(Menu menu) … Read more

Android Change Navigation Drawer Menu Items Text programmatically

You can change the title of Navigation Menu Item programmatically by adding following lines in MainActivity.java file. @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); … //other stuff here … NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); // get menu from navigationView Menu menu = navigationView.getMenu(); // find MenuItem you want to change MenuItem nav_camara = menu.findItem(R.id.nav_camara); … Read more

How to add “active” class to wp_nav_menu() current menu item (simple way)

Just paste this code into functions.php file: add_filter(‘nav_menu_css_class’ , ‘special_nav_class’ , 10 , 2); function special_nav_class ($classes, $item) { if (in_array(‘current-menu-item’, $classes) ){ $classes[] = ‘active ‘; } return $classes; } More on wordpress.org: Highlight Current Page in WordPress 3.0 Menus Adding .active class to active menu item

Is it possible to grey out (not just disable) a MenuItem in Android?

On all android versions, easiest way to use this to SHOW a menu action icon as disabled AND make it FUNCTION as disabled as well: @Override public boolean onPrepareOptionsMenu(Menu menu) { MenuItem item = menu.findItem(R.id.menu_my_item); if (myItemShouldBeEnabled) { item.setEnabled(true); item.getIcon().setAlpha(255); } else { // disabled item.setEnabled(false); item.getIcon().setAlpha(130); } }

WPF – how to hide menu item if command’s CanExecute is false?

Thanks for the solution. For those wanting explicit XAML this might help: <Window.Resources> <BooleanToVisibilityConverter x:Key=”booleanToVisibilityConverter” /> </Window.Resources> <ContextMenu x:Key=”innerResultsContextMenu”> <MenuItem Header=”Open” Command=”{x:Static local:Commands.AccountOpened}” CommandParameter=”{Binding Path=PlacementTarget.DataContext, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ContextMenu}}}” CommandTarget=”{Binding Path=PlacementTarget, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ContextMenu}}}” Visibility=”{Binding Path=IsEnabled, RelativeSource={RelativeSource Self}, Mode=OneWay, Converter={StaticResource booleanToVisibilityConverter}}” /> </ContextMenu> In my case, the context menu is a resource, so the … Read more

How can I dynamically create menu items?

How to Dynamically Add Menu Items to an Android Activity public class yourActivity extends Activity { … private static final int MENU_ADD = Menu.FIRST; private static final int MENU_LIST = MENU.FIRST + 1; private static final int MENU_REFRESH = MENU.FIRST + 2; private static final int MENU_LOGIN = MENU.FIRST + 3; /** * Use if … Read more

How to set icon color of MenuItem?

The icon is actually provided by the ShareActionProvider and you can’t change it afaik. You can, however, customize the color by setting the textColorPrimary in your styles.xml: <android.support.v7.widget.Toolbar android:id=”@+id/toolbar” android:layout_width=”match_parent” android:layout_height=”?attr/actionBarSize” app:theme=”@style/MyActionBarTheme” app:popupTheme=”@style/ThemeOverlay.AppCompat.Light”> <style name=”MyActionBarTheme” parent=”ThemeOverlay.AppCompat.Dark.ActionBar”> <item name=”android:textColorPrimary”>#fa0</item> </style> For any custom icons, you would have to color them yourself, ie. @Override public boolean onCreateOptionsMenu(Menu … Read more

Android : Get view Reference to a Menu Item

You can achieve this by providing your menu item with an actionViewClass property in xml and then you will be able to get the pivot view u wanted. The code would be something like this <item android:id=”@+id/menu_find” android:showAsAction=”ifRoom” android:actionViewClass=”android.widget.ImageButton” /> In your OnCreateOptionsMenu do this public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); getMenuInflater().inflate(R.menu.menu_search, menu); locButton = … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)