Option menu checkbox android - android

I have a problem with the option menu checkable item
I want the checkbox be placed right of title not under it.
He is my option.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">
<group android:checkableBehavior="single">
<item android:id="#+id/notif"
android:title="Notification"
android:checkable = "true"/>
</group>
</menu>
Thanks.

This will only be the case in the menu preview in Android Studio. On your device it will display as expected.
For example:
In Android Studio, mine looks like yours:
When I start the application and check, it looks like I expect:
Hope this helped!

Related

In Navigation Architecture is it possible to replace ActionBar menu completely?

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

Navigation Drawer showing only black icons

I want to change navigation drawer icons, i am trying below code in Menu.xml file. But it showing only black icon.
<?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=".Welcome"
tools:showIn="navigation_view">
<group android:checkableBehavior="single">
<item
android:id="#+id/nav_kirtan"
android:icon="#drawable/point_red"
android:title="XYZ"/>
</group>
Expected output -
Please help me...!
Add below line in Activity class...
mNavigationView.setItemIconTintList(null);
Try to add color like this :
<item
android:id="#+id/nav_kirtan"
android:icon="#drawable/point_red"
android:title="XYZ"
android:tint="#color/redColor"
/>
or you can also do
mNavigationView.setItemIconTintList(null);
This disables all state based tinting.

i can't add the menu icons to the tool bar in visual studio xamarin

it seems that what ever i did i cant set the icons visible to the tool bar, i've tried to do researches on many platforms, but nothing helped.
here is the xml menu:
<?xml version="1.0" encoding="utf-8" ?>
<menu
xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="#+id/event_ic"
android:icon="#mipmap/ic_event"
android:title="profile"
android:showAsAction="always"
/>
<item
android:id="#+id/details_menu"
android:title="details"
android:showAsAction="never"/>
</menu>
you can see that even if i set the android:showAsAction to always, i still get the event item in the pop up menu without the icon.

Force to show icon + text toolbar menu item

<item
android:icon="#drawable/ic_public_white_24dp"
android:id="#+id/action_public"
android:orderInCategory="0"
android:title="Public"
app:showAsAction="always|withText">
I have this item, I am trying to force to show simultaneously.
If I remove the icon, appears the text "Public", but if I have icon then only appear it.
Is it possible to force to show both? I read a lot of info about it and this app:showAsAction="always|withText" should force this...
I tried this:
<?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"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".MainActivity">
<item
android:icon="#drawable/ic_public_white_24dp"
android:id="#+id/action_public"
android:orderInCategory="0"
android:title="Public"
app:showAsAction="always|withText">
And it is not working for me.
I am in Android Studio 3.0 beta 5

Highlight background color in specific pages

I have 2 activities in my app. I navigate between them using a NavigationDrawer.
Activity A is "Mes cours" and Activity B is "Mes branches".
When I'm on Activity A, I'd like to change the background of the item "Mes cours", so the user knows that he's in that page.
But if I'm in Activity B, I'd like to change the background of "Mes branches".
Everything works fine, but I want to solve that problem of changing the background...
I'm using the same menu for those 2 pages. How can I do it so ?
Thank you guys.Tell me if you need more code.
My menu.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/menu_navigation">
<item
android:id="#+id/mes_cours"
android:title="Mes cours"/>
<item
android:id="#+id/mes_branches"
android:title="Mes branches"/>
</menu>
This is done by using
navigationView.getMenu().getItem(0).setChecked(true);
Here getItem(0) refers to 1st item, so for 2nd item change it to getItem(1)
Hope this helps you :)
You need to add
<group android:checkableBehavior="single">
to your following code after menu, like written under
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group android:checkableBehavior="single"
>
<item
android:id="#+id/mes_cours"
android:title="Mes cours"/>
<item
android:id="#+id/mes_branches"
android:title="Mes branches"/>
</group>
</menu>

Categories

Resources