How can I refresh the ActionBar when onPrepareOptionsMenu switched menu entries?

My method of choice is to create a helper class. For example: class VersionHelper { static void refreshActionBarMenu(Activity activity) { activity.invalidateOptionsMenu(); } } Now in your code above, replace invalidateOptionsMenu(); with: if (Build.VERSION.SDK_INT >= 11) { VersionHelper.refreshActionBarMenu(this); } Credit for this method goes to CommonsWare (search for HoneycombHelper, and check out his books – highly … Read more

Differences between .ContextMenu and .ContextMenuStrip

http://www.informit.com/articles/article.aspx?p=606224&seqNum=2 You might wonder why Microsoft has replaced a valuable and popular control with a newcomer. The ContextMenuStrip control takes a good idea and makes it better. It works just like the ContextMenu control. You still attach a ContextMenuStrip control to another user control by changing that control’s ContextMenuStrip property. However, Microsoft has substantially improved … Read more

active menu item – asp.net mvc3 master page

A custom HTML helper usually does the job fine: public static MvcHtmlString MenuLink( this HtmlHelper htmlHelper, string linkText, string actionName, string controllerName ) { string currentAction = htmlHelper.ViewContext.RouteData.GetRequiredString(“action”); string currentController = htmlHelper.ViewContext.RouteData.GetRequiredString(“controller”); if (actionName == currentAction && controllerName == currentController) { return htmlHelper.ActionLink( linkText, actionName, controllerName, null, new { @class = “current” }); } return … Read more

‘setHasOptionsMenu(Boolean): Unit’ is deprecated. Deprecated in Java

From the Developer documentation, this can be achieved by the following: /** * Using the addMenuProvider() API directly in your Activity **/ class ExampleActivity : ComponentActivity(R.layout.activity_example) { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) // Add menu items without overriding methods in the Activity addMenuProvider(object : MenuProvider { override fun onCreateMenu(menu: Menu, menuInflater: MenuInflater) { // … 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

creating a menu after a long click event on a list view

First you need to register your context menu on list view. lv = (ListView) findViewById(R.id.list_view); registerForContextMenu(lv); Then, just override activity methods. /** * MENU */ @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); if (v.getId()==R.id.list_view) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.menu_list, menu); } } @Override public boolean onContextItemSelected(MenuItem item) { … Read more

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