InterviewSolution
Saved Bookmarks
| 1. |
I have created one background service playing music in the background. If I need to make Foreground what steps do I have to follow? |
|
Answer» Menu Item is part of the menu.xml file. When we want to ADD a menu in-out activity we need to method OnCreateOptionMenu(Menu menu). But If you want to add any Menu Item at run time then the system calls your activity’s onPrepareOptionsMenu() method. this method passes currently exist menu OBJECT to MODIFY the menu item. Please follow the below code for more DETAIL: @Override public boolean onPrepareOptionsMenu(Menu menu) { if(Build.VERSION.SDK_INT > 11) { invalidateOptionsMenu(); menu.findItem(R.id.option1).setVisible(false); menu.findItem(R.id.option2).setVisible(true); } return super.onPrepareOptionsMenu(menu); |
|