How to display menu item with icon and text in AppCompatActivity

@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_patient_home_screen, menu); menu.add(0, 1, 1, menuIconWithText(getResources().getDrawable(R.mipmap.user_2), getResources().getString(R.string.action_profile))); menu.add(0, 2, 2, menuIconWithText(getResources().getDrawable(R.mipmap.add_user), getResources().getString(R.string.action_add_user))); menu.add(0, 3, 3, menuIconWithText(getResources().getDrawable(R.mipmap.switch_profile), getResources().getString(R.string.action_switch_profile))); menu.add(0, 4, 4, menuIconWithText(getResources().getDrawable(R.mipmap.logout), getResources().getString(R.string.action_sign_out))); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle … 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

WPF – How can I create menu and submenus using binding

For me, it worked with this simple template: <Menu.ItemContainerStyle> <Style TargetType=”{x:Type MenuItem}”> <Setter Property=”Command” Value=”{Binding Command}” /> </Style> </Menu.ItemContainerStyle> <Menu.ItemTemplate> <HierarchicalDataTemplate DataType=”{x:Type local:MenuItemViewModel}” ItemsSource=”{Binding Path=MenuItems}”> <TextBlock Text=”{Binding Header}”/> </HierarchicalDataTemplate> </Menu.ItemTemplate> Here is the complete example: MainWindow.xaml: <Window x:Class=”WpfApplication14.MainWindow” xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation” xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml” xmlns:local=”clr-namespace:WpfApplication14″ Title=”MainWindow” Height=”350″ Width=”525″> <DockPanel> <Menu DockPanel.Dock=”Top” ItemsSource=”{Binding MenuItems}”> <Menu.ItemContainerStyle> <Style TargetType=”{x:Type MenuItem}”> <Setter Property=”Command” … Read more

Sql Server ‘Saving changes is not permitted’ error ► Prevent saving changes that require table re-creation

From Save (Not Permitted) Dialog Box on MSDN : The Save (Not Permitted) dialog box warns you that saving changes is not permitted because the changes you have made require the listed tables to be dropped and re-created. The following actions might require a table to be re-created: Adding a new column to the middle … Read more

Handling a Menu Item Click Event – Android

Simple code for creating menu. @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.game_menu, menu); return true; } Simple code for menu item selection @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle item selection switch (item.getItemId()) { case R.id.new_game: newGame(); return true; case R.id.help: showHelp(); return true; default: return super.onOptionsItemSelected(item); } } You … Read more

Android 4.3 menu item showAsAction=”always” ignored

Probably you are missing required namespace: <menu xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:[yourapp]=”http://schemas.android.com/apk/res-auto”> <item android:id=”@+id/menu_add_size” android:title=”@string/menu_add_item” android:orderInCategory=”10″ [yourapp]:showAsAction=”always” android:icon=”@android:drawable/ic_menu_add” /> </menu> Replace [yourapp] with your app name or any namespace your heart desires everywhere. Other things worth checking: See if your activity class extends ActionBarActivity Check if the issue persists. Android reference documentation: Adding Action Buttons. Here is the … Read more