Menu item icon now showing in sub menu - android

I'm using topup sub-menu item by group in menu item. I have created group item menu as given below menu xml code.
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:cycle="http://schemas.android.com/apk/res-auto" >
<group>
<item
android:id="#+id/bookAppt"
android:icon="#drawable/addsomething_gray"
android:orderInCategory="1"
android:title="Book Appointment"
cycle:showAsAction="never"/>
<item
android:id="#+id/refreshAppt"
android:icon="#drawable/refresh_icon_dark"
android:orderInCategory="2"
android:title="Refresh"
cycle:showAsAction="never"/>
</group>
Every thing going perfect but submenu item icon not showing. Can anyone guide me regarding this issue.
Thanks

In your code change this cycle:showAsAction="never" to cycle:showAsAction="always".

replace cycle:showAsAction="never" with app:showAsAction="ifRoom|always"

Related

Popup Dialog as Menu when Menu is clicked

I want to implement Dialog where I will be able to set values.
I also would want to Dialog will Popup when I click on three dots (Menu) on Toolbar.
So far I've got menu
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
>
<item
android:id="#+id/menu_allclients_min_date"
android:orderInCategory="200"
android:title="#string/menu_min_date"
app:showAsAction="never" />
<item
android:id="#+id/menu_allclients_max_date"
android:orderInCategory="201"
android:title="#string/menu_max_date"
app:showAsAction="never" />
<item
android:id="#+id/menu_allclients_min_amount"
android:orderInCategory="202"
android:title="#string/menu_min_amount"
app:showAsAction="never" />
<item
android:id="#+id/menu_allclients_max_amount"
android:orderInCategory="203"
android:title="#string/menu_max_amount"
app:showAsAction="never" />
Now, when Menu is clicked it show as list of four items. But It isn't a way I want to implement it.
I would also know is there any listener when Menu icon( three dots ) is clicked. It would solve my problem.
For help i sugest, if you dont have more than 2 menu itens, make a menu item set the 3 dots as icon and always as showasaction. After that in on menu item selected in your activity make a switch to check item selected and if is the 3 dots item make the dialog.

android fragment activity menu

I have a class that extends FragmentActivity. No I want to show my menu items at the top of the screen like in actionbar. How can I do this ?
I have created the menu items and they are visible hen the hardware button for menu is pressesd but I want to sho them at the top of the screen.
Basically, this happens in devices with physical menu button. In devices without that button, all options are displayed in the action bar.
You can force a menu item to be displayed in the action bar by addind "showAlways" to the item that you want.
showAsAction=“always”
An small example
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="#+id/action_search"
android:icon="#drawable/ic_action_search"
android:title="#string/action_search"
android:showAsAction="always" />
<item android:id="#+id/action_settings"
android:title="#string/action_settings"
android:showAsAction="always" />
</menu>
You must need to ensure that you have enough space for the menu items.
To ensure that I'll have enough space, I use to create a menu with only one item. Then, inside this item, I create another menu. This way, only one button is displayed and all items appear in a floating pop up menu. The main idea is below:
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="#+id/overflow_item"
android:icon="#drawable/ic_overflow_icon"
android:title="#string/options"
android:showAsAction="always" />
<menu>
<item android:id="#+id/action_clear"
android:title="#string/clear"
android:showAsAction="always" />
</menu>
</menu>

Keeping Android Menu Items opened after clickng on one of the items

Can I alter the default behavior of the action bar items menu so the menu doesn't close automatically when any of its items is checked ?
I tried returning false to OnOptionsItemSelected method. Also , I tried to add this line to OnCreateOptionsMenu
menu.PerformIdentifierAction(Resource.Id.fs_action_statusFilter, MenuPerformFlags.PerformNoClose);
You can add a sub menu to an item in your menu by adding a menu element as the child of an item. So the sub menu will open when its parent menu is checked. For example:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="#+id/file"
android:title="#string/file" >
<!-- "file" submenu -->
<menu>
<item android:id="#+id/create_new"
android:title="#string/create_new" />
</menu>
</item>
</menu>

What is orderInCategory in ActionBar menu item & why it is use for..?

Im working on action menu item and its over flow item this is my main_menu.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="#+id/menu_search"
android:icon="#drawable/search"
android:title="#string/start_new_project"
app:showAsAction="always" />
<item
android:id="#+id/menu_dts_overflow"
android:icon="#drawable/ic_action_overflow_round"
android:orderInCategory="11111"
android:title="Service"
app:showAsAction="always">
<menu>
<item
android:id="#+id/menu_newProject"
android:icon="#drawable/newproject"
android:title="#string/start_new_project"
app:showAsAction="never" />
<item
android:id="#+id/menu_help"
android:icon="#drawable/help"
android:title="Service Tasks"
app:showAsAction="never" />
<item
android:id="#+id/menu_signOut"
android:icon="#drawable/signout"
android:title="#string/menusignout"
app:showAsAction="never" />
</menu>
</item>
I tried to construct a search item and a overflow item which you can see in the above code. I'm new to Action bar menu items so i tried to Google it and was able to make it work as I need.
In this I have to know one more thing.
1. What is orderInCategory with some numbers and what for it is used..?
android:orderInCategory is an integer attribute that dictates the order in which the menu items will appear within the menu when it is displayed.
<menu
xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="#+id/menu_item_first"
android:orderInCategory="1"
android:showAsAction="never"
android:title="#string/string_one"/>
<item
android:id="#+id/menu_item_second"
android:orderInCategory="2"
android:showAsAction="never"
android:title="#string/string_two"/>
</menu>
Menu items in ToolBar are arranged from left to right (or
start to end in RTL mode) in the ascending order (i.e. 1,2,3 ->
left to right).
Menu Items in Overflow menu are arranged from top to bottom in
the ascending order (i.e. 1,2,3 -> top to bottom).
android:orderInCategory is actually useful in two ways.
1. For menu items in ActionBar.
Items will appear from left to right in ActionBar depending on the ascending order.
2. For menu items in overflow menu.
Overflow menu items will be displayed from top to bottom depending upon the ascending order you have specified.
android:orderInCategory Higher value, lower priority.
I have a Activity and a Fragment in it, both of them have option menu, and the item numbers are 1 and 3.
If I set android:orderInCategory=0, the activity menu are above the fragment menu, same effect before I set the value.
But if I set android:orderInCategory=1,the activity menu are below the fragment menu, and that is what I want.(I also test android:orderInCategory=5 tested too, still the same effect.)

contextual action bar - getting rid of Select Action text

I've implemented a contextual action bar. The menu being loaded and inflated in onCreateActionMode is defined as follows:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
android:title="#string/call_context_menu_title">
<item android:id="#+id/menu_answer_call"
android:title="#string/answerCall"
android:showAsAction="ifRoom" />
<group android:id="#+id/activeCallContextMenuItems">
<item android:id="#+id/menu_end_call"
android:title="#string/hangupCall"
android:showAsAction="ifRoom"/>
<group android:id="#+id/multipleActiveCallsContextMenuItems">
<item android:id="#+id/menu_transfer_call"
android:title="#string/transferCall"
android:showAsAction="ifRoom"/>
<item android:id="#+id/menu_conference_call"
android:title="#string/conferenceCall"
android:showAsAction="ifRoom"/>
</group>
</group>
</menu>
These items are shown when I click on an item in a ListView. When it is active, besides listing my 4 options, it puts a "Select Action" text before the first menu item. Is there any way to get Android to not show the "Select Action" hint? The menu items have self explanatory text so it is redundant (and even confusing if the hint is being cut off in the middle... e.g. on my S3 it says "Select..." and then I have my menu items)

Categories

Resources