I actually have two questions:
Is there a way to mark a menu item in the ActionBar as the OK/submission button, or is it just a regular item?
Is there a built-in theme for an OK button in the ActionBar (maybe something that looks like a tick-mark?) or must I create my own image file?
I found this icon in Sherlock, it looks like a tick mark and it seems to do the job:
abs__ic_cab_done_holo_light.png
So this is my menu xml (located in res/menu):
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="#+id/done_item"
android:icon="#drawable/abs__ic_cab_done_holo_light"
android:showAsAction="always"
android:orderInCategory="1"
android:title="#string/done">
</item>
</menu>
Related
I want to know if there a solution to add an image next to a text in the option menu in xml like the photo:
by adding icon attribute to your menu item xml and setting show as action to never like that :
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="#+id/favorite"
android:icon="#drawable/ic_favorite_24dp"
android:title="#string/favorite"
android:contentDescription="#string/content_description_favorite"
app:showAsAction="never" />
</menu>
where the ic_favorite_24dp could be any image/vector asset icon drawable you like in your drawables folder.
check this link and this link for more information
I'm using AndroidX Navigation architecture and want to know is it possible to replace the ActionBar menu completely or not?
In the project, in the Menu directory, there is a home.xml file that contains a menu items:
<?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"
android:id="#+id/homeMainMenu">
<item
android:id="#+id/action_inbox"
android:icon="#drawable/ic_baseline_mail_outline_24"
android:title="#string/action_inbox"
app:showAsAction="ifRoom" />
<item android:icon="#drawable/ic_baseline_more_vert_24"
android:title="#string/app_name"
app:showAsAction="always">
<menu>
<item
android:id="#+id/action_exitapp"
android:icon="#drawable/ic_baseline_exit_to_app_24"
android:title="#string/action_exit"
app:showAsAction="never" />
</menu>
</item>
</menu>
I want to create another menu XML file like mymenu.xml and on the fragment replace it with the home menu. Because of some reason don't want to replace items.
Is it possible? If "Yes" how to handle item click?
If i got your question correct then i guess you want to create different menu for activity and its fragment. You can do that. Please check here
Remember you've to add hasOptionsMenu in fragment onCreate
I have tried every option of the android:showAsAction, and it didn't work!
I think that maybe I can't get the concept of how to do it.
my app
how I want it
Try something like this.
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="#+id/action_cart"
android:icon="#drawable/ic_action_cart"
android:title="Refresh"/>
<item
Your items
</item>
</menu>
http://www.vogella.com/tutorials/AndroidActionBar/article.html
Please take in consideration that I'm refering to the Toolbar Widget(Android L/API 21+)
By overflow menu and icons I mean something like this one :
Something more difficult : Is there any way that the icons appear on the RIGHT side of the text?
create a menu in menu, for example: main_activity_actions.xml
and use this code for the toolbar, try it:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:All4One="http://schemas.android.com/apk/res-auto">
<item android:id="#+id/algo"//some id
android:icon="#drawable/kami_nomi_zu_shiru_sekai3" //add the image
android:title="nose"
All4One:showAsAction="always">
<menu>
<item android:id="#+id/WIFI"//option to display on the menu
android:icon="#drawable/nisekoi1"//this is a option of the submenu
android:title="#string/WIFI"/>
<item android:id="#+id/DATOS"
android:icon="#drawable/nisekoi6" //this one also is a option
android:title="#string/DATOS"/>
<item android:id="#+id/BT"
android:icon="#drawable/sao1"
android:title="#string/BT"/>
<item android:id="#+id/NADA"
android:icon="#drawable/nisekoi6" //the same
android:title="#string/NADA"/>
</menu>
</item>
</menu>
I've set up a simple menu with one position like this:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" tools:context=".MainActivity">
<item android:id="#+id/action_language" android:title="#string/language"
android:orderInCategory="100" />
</menu>
using
Theme.AppCompat.Light.DarkActionBar
style. When I click the three dots the menu position appears instead of the icon, not below it? Is there any way to make it appear under the icon, not 'on' it?
Actually you can't do anything with this icon, but you can create menu item with android:actionLayout="#layout/custom_lauout". Then you can create Popup Window, which allows such positioning. In popupWindow you will show all items that must show under "three dots item".
Here rea a few links which can help you: http://developer.android.com/reference/android/widget/PopupWindow.html
https://stackoverflow.com/a/23516493/3864698