Questions tagged [oncreateoptionsmenu]

112 questions
3
votes
1 answer

onCreateOptionsMenu Inflater doesn´t work in Android Java Class

in my code i want to infalte an action bar with a menu, but it doesn´t works. I have more Activities ( Start, Karte, Teilnehmer ) on all three I had place the onCreateOptionsMenu block but only on Karte it works. If anyone can help me, please…
Antonio Gschossmann
  • 532
  • 1
  • 7
  • 18
3
votes
1 answer

Activity doesn't show actionbar

I joined Android Studio and Android App project a few week ago, and I'm trying to create a simple app with ActionBar options. When I start Android Studio, following Android Dev. Training, I meet always this rendering error: Android Studio doesn't…
3
votes
2 answers

Android NullPointerException on onCreateOptionsMenu

This is my code: public class className extends Activity{ private MenuActivity menuActivity; @Override public void onCreate(Bundle savedInstanceState) { try { ViewConfiguration config = ViewConfiguration.get(this); …
2
votes
4 answers

Unable to set menu for fragment

Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setHasOptionsMenu(true); Log.i("frag", "onCreate"); } @Override public View onCreateView(LayoutInflater inflater, ViewGroup…
2
votes
4 answers

What does this method do super.onCreateOptionMenu() and super.onOptionsItemSelected(item)

I am new to android. I know this question have been asked before but, i am still confuse . What this method does when returning them inside my onCreateOptionMenu() and onOptionItemSelected() Can any one help me what effect i will have 1)if i return…
FaisalAhmed
  • 3,469
  • 7
  • 46
  • 76
2
votes
2 answers

Android Options Menu on Action bar shows duplicate icons

action bar (Toolbar) on android has 3 options menu. Its working fine. But the problem is when ever i am uninstalling and reinstalling this duplication of the menu item is showing. Also the Title is also remains same, not changing. after sometimes,…
2
votes
1 answer

Why does Activity's method onCreateOptionMenu() get called two times by using setHasOptionMenu(true) for it's Fragments?

I manage some Fragment's in my own ActionBarActivity named MainActivity. One Fragment is shown at one time. The example should be simple. The Fragment which is showing should have got an option menu under certain conditions. Here my code: public…
2
votes
0 answers

Is it possible to create option menu when window is set to full screen?

Is it possible to create option menu when window is set to full screen? And how do I set the window to full screen inside option menu? Inside onCreate i had to commandline the code because i was not able see the option menu when the screen is set…
nandu
  • 123
  • 1
  • 9
2
votes
1 answer

Android support library v7, can't get ActionProvider

I have custom ActionProvider like this. .... import android.support.v4.view.ActionProvider; public class MyActionProvider extends ActionProvider { .... } And in menu.xml
2
votes
3 answers

SherlockFragment onCreateOptionsMenu is not calling

In my app I'm having a class which extends SherlockFragmentActivity. Within that Activity, I'm loading four classes which extends SherlockFragment which pretends as Tabs with the help of ActionbarSherlock and PagerSlidingTabStrip. The classes which…
1
vote
1 answer

Set searchView focused when activity opens android

I have a SearchActivity with a menu that holds a searchView.
james04
  • 1,580
  • 2
  • 20
  • 46
1
vote
3 answers

kotlin.TypeCastException: null cannot be cast to non-null type

I am trying to initialize custom search tool (3d library ) on menu but I got error. Here is my code override fun onCreateOptionsMenu(menu: Menu?): Boolean { menuInflater.inflate(R.menu.base_nav_drawer,menu) searchItem=…
1
vote
1 answer

SearchView is not displayed on toolbar with nested Fragments

I must have read almost all the question and answers related to this, but still cannot get it to work. Below is the rough sketch of how the app looks. Adding code below to give structure of the layout and where I might be doing…
1
vote
1 answer

OnClick Return wrong position and data to filtered text on listvew

Respectable Gurus Bellow code return wrong position and data by clicking on listview filtered Item of ArrayAdapter, Any Suggestion will by highly appreciated. Listview can be easily and perfectly filtered by bellow code by on setOnItemClickListener`…
1
vote
0 answers

Menu not created with Collapsing toolbar

I have a collapsing toolbar in my fragment and fragment has its own toolbar. The onCreateOptionsMenu is not being called. This worked when fragment was using activity's toolbar, now while refactoring toolbar, so that each fragment has its own,…