112 questions
-3
votes
1
answer
147
views
Menu is not showing when I run my app in android studio [closed]
I created the menu directory inside res to create main_menu.xml after creating the xml file for the menu I added 2 items. These items are just 2 icons with a title & id. I used @override method of ...
0
votes
1
answer
566
views
Kotlin: Make the options menu visible only in a specific toolbar
There are three types of toolbar used in this app. (toolbar, toolbar2, toolbar3)
The MainActivity is connected to four fragments through the bottom navigation bar. (home, community, calendar, mypage)
...
0
votes
0
answers
87
views
How do I call onCreateMenuOptions just once when the fragment is being created
My activity contains many fragments and it has been found that every time a bottom sheet fragment opens up in the activity, the onCreateOptionsMenu function gets called again. How do I ensure that the ...
1
vote
1
answer
577
views
Options menu inflate wrongly in viewpager2
I have 4 fragments but for each fragments it has different different menu options in my app with viewpager2 so the user swipe through these all fragments and when the app starts the menu option for ...
0
votes
1
answer
67
views
Programatically create checkbox menu in fragment java
I am having a Fragment and below is how i am adding menus in my onCreateOptionsMenu programatically
@Override
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
...
0
votes
1
answer
80
views
onCreateOptionsMenu showing alwasy as action with a menu that i have created programatically
Below is how i have created my menu programmatically
@Override
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
...
0
votes
1
answer
88
views
Cannot call inline fun SearchView.OnQueryTextListener from onCreateOptionsMenu
In this app I tried to implement SearchView.OnQueryTextListener in separate kotlin file like this
import androidx.appcompat.widget.SearchView
inline fun SearchView.OnQueryTextListener(crossinline ...
0
votes
1
answer
801
views
Android onCreateOptionsMenu declaration in a fragment failing with "Accidental Override"
I have some Kotlin code that is attempting to tweak the visibility of some option menu items inside a fragment using onCreateMenuOptions. Kotlin is complaining about an accidential override, and there ...
1
vote
1
answer
644
views
Set searchView focused when activity opens android
I have a SearchActivity with a menu that holds a searchView.
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android&...
0
votes
0
answers
161
views
Search Menu not showing in Fragment
I was trying to build a simple fragment in which to show search on the menu, in the debugging doesn't stop at the class.
I have other classes for the main Fragment and other 2 fragments, I want to ...
0
votes
0
answers
45
views
What is safe to put in OnCreateOptionsMenu in Android Activity?
In my app I have a Spinner as a menu item in the action bar of my Activity. It has the collapsible action view so it appears only when the icon is clicked. I obtain a reference to my Spinner like this:...
0
votes
0
answers
108
views
crash on MainMenu.onCreateOptionsMenu
When I test my app on Xiaomi A2, it runs fine. When I upload to Google Play, it crashes.
Stack Trace on Play console reads:
java.lang.NullPointerException:
at com.thongjoon.ocsc_exam_prep.MainMenu....
0
votes
1
answer
735
views
How do I only trigger onPrepareOptionsMenu and not onCreateOptionsMenu?
According to the Android menu documentation and a similar question, onPrepareOptionsMenu should be used to update menus dynamically. For Android 3.0 and higher, the documentation says:
When an event ...
-1
votes
1
answer
31
views
I´m trying to call other activity with MenuItem
I`m trying to call other activity with onCreateOptionsMenu and onOptionsItemSelected, but i dont know is imposible to debug and it doesn´t do the action, i have
@Override
public boolean ...
0
votes
1
answer
94
views
Android 5 portrait app crashes when going to Recents and rotating
The activities of my app have all the attribute to make them portrait:
android:screenOrientation="portrait"
The minSdkVersion of the app is 21. With Android 5.0 phones the app crashes if the device ...