android: changing option menu items programmatically

For anyone needs to change the options of the menu dynamically: private Menu menu; // … @Override public boolean onCreateOptionsMenu(Menu menu) { this.menu = menu; getMenuInflater().inflate(R.menu.options, menu); return true; } // … private void hideOption(int id) { MenuItem item = menu.findItem(id); item.setVisible(false); } private void showOption(int id) { MenuItem item = menu.findItem(id); item.setVisible(true); } private … 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

Android: How to enable/disable option menu item on button click?

Anyway, the documentation covers all the things. Changing menu items at runtime Once the activity is created, the onCreateOptionsMenu() method is called only once, as described above. The system keeps and re-uses the Menu you define in this method until your activity is destroyed. If you want to change the Options Menu any time after … Read more

How do I center align horizontal menu?

From http://pmob.co.uk/pob/centred-float.htm: The premise is simple and basically just involves a widthless float wrapper that is floated to the left and then shifted off screen to the left width position:relative; left:-50%. Next the nested inner element is reversed and a relative position of +50% is applied. This has the effect of placing the element dead … Read more

How do I hide a menu item in the actionbar?

Get a MenuItem pointing to such item, call setVisible on it to adjust its visibility and then call invalidateOptionsMenu() on your activity so the ActionBar menu is adjusted accordingly. Update: A MenuItem is not a regular view that’s part of your layout. Its something special, completely different. Your code returns null for item and that’s … 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

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