I want to show navigation menu item on fragment activity. there are 4 item of navigation item . I want to show it on fragment with list view. i want to show on both navigation menu and fragment activity. after click showing same page individually.
<?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:showIn="navigation_view">
<group android:checkableBehavior="single">
<item
android:id="#+id/adviser"
android:icon="#drawable/ic_person"
android:title="Adviser" />
<item
android:id="#+id/executive"
android:icon="#drawable/ic_group"
android:title="#string/exce" />
<item
android:id="#+id/member"
android:icon="#drawable/ic_people"
android:title="#string/mem" />
<item
android:id="#+id/alumni"
android:icon="#drawable/ic_school"
android:title="#string/alu" />
</group>
<item android:title="Informations">
<menu>
<item
android:id="#+id/aboutrudf"
android:icon="#drawable/ic_info"
android:title="#string/abo" />
</menu>
</item>
</menu>
there's template for creating new activity click new > activity
Related
I'm using Navigation Drawer. I've used a spinner layout in a menu item, but it looks bad. I'm trying to have a view like this, but IDK how.
So when I press PRODUCT, a dropdown submenu appears.
I've tried this code to do so but it's not working.
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:showIn="navigation_view">
<group android:checkableBehavior="single"
>
<item
android:id="#+id/nav_home"
android:checkable="true"
android:icon="#drawable/ic_outline_home_24"
android:title="#string/home" />
<item
android:id="#+id/nav_products"
android:checkable="true"
android:visible="true"
android:actionLayout="#android:layout/simple_spinner_dropdown_item"
android:icon="#drawable/ic_outline_shopping_bag_24"
app:showAsAction="collapseActionView"
android:title="#string/products" >
<menu>
<item
android:id="#+id/fire_alam"
android:title="#string/fire_alarms"
android:checkable="true"
app:showAsAction="never"
/>
<item
android:id="#+id/fire_fighting"
android:checkable="true"
app:showAsAction="never"
android:title="#string/fire_fighting"/>
</menu>
</item>
<item
android:id="#+id/nav_serv"
android:checkable="true"
android:icon="#drawable/ic_outline_room_service_24"
android:title="#string/services" />
</group>
</menu>
You can use ExpandableListView
Check:- https://www.journaldev.com/9942/android-expandablelistview-example-tutorial
Also you can use it in NavigationView
Check:-
https://www.journaldev.com/19375/android-expandablelistview-navigationview
I have a fragment with an actionbar and one icon, and another fragment which is placed over the first one with it's own actionbar and two icons. I have it so the second fragment will show all three items in the actionbar and the first one shows only it's one:
fragment with 3 items
fragment with 1 item
I'd like the red square in the fragment with 3 items to be on the right hand side of the other two items.
Fragment layout for 2 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">
<item
android:title="#string/menu_sort"
android:id="#+id/menu_sort"
app:showAsAction="always"
android:icon="#drawable/ic_baseline_sort_24">
<menu>
<item android:title="Distance"/>
<item android:title="Salary"/>
<item android:title="Date Posted"/>
</menu>
</item>
<item
android:title="#string/menu_filter"
android:id="#+id/menu_filter"
app:showAsAction="always"
android:icon="#drawable/ic_baseline_filter_list_24">
<menu>
<item android:title="Freelance"/>
<item android:title="Zero Hour"/>
<item android:title="Part Term"/>
<item android:title="Internship"/>
</menu>
</item>
</menu>
Fragment layout for 1 item:
<?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:title="#string/menu_profile"
android:id="#+id/menu_profile"
app:showAsAction="always"
app:actionLayout="#layout/profile_menu_layout"/>
</menu>
Profile_menu_layout used above:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:padding="5dp"
android:clickable="true"
>
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/toolbar_profile_image"
android:layout_width="30dp"
android:layout_height="30dp"
android:src="#mipmap/ic_launcher"/>
</FrameLayout>
You could achieve this by setting the android:orderInCategory on the menu items. For reference..
I am trying to add Menu item(action_collapse_expand) next to another menu item. Problem is that item is added to expandable list(three dots icon), but not as separate icon. I've just started learning Android and I would like to know what am I doing wrong.
<?xml version="1.0" encoding="utf-8" ?>
<!--For all properties see: http://developer.android.com/guide/topics/resources/menu-resource.html-->
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="#+id/action_collapse_expand"
android:icon="#drawable/drag_drop"
android:title="Collapse"
android:showAsAction="always|withText" />
<item android:id="#+id/add" android:showAsAction="never" android:title="add" android:icon="#drawable/Add">
<menu>
<item android:id="#+id/map" android:showAsAction="always|withText" android:title="map" android:icon="#drawable/Map" />
<item android:id="#+id/mapK" android:showAsAction="always|withText" android:title=mapK" android:icon="#drawable/MapK" />
</menu>
</item>
<item android:id="#+id/exit" android:showAsAction="always" android:title="Exit" android:icon="#drawable/Close" />
</menu>
Try replacing android:showAsAction with app:showAsAction.
Don't forget to add xmlns:app="http://schemas.android.com/apk/res-auto" under your menu tag.
I have a navigation drawer. In the menu, I am trying to use some icons to the items in the menu but they don't appear. it looks like this.
here is the XML for the menu
<?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:showIn="navigation_view">
<group android:checkableBehavior="single">
<item
android:id="#+id/nav_overview"
android:icon="#drawable/ic_bell"
android:title="#string/overview" />
<item
android:id="#+id/nav_symptoms"
android:icon="#drawable/ic_symptoms"
android:title="#string/symptoms" />
<item
android:id="#+id/nav_prevention"
android:icon="#drawable/ic_preventation"
android:title="#string/prevention" />
<item
android:id="#+id/nav_treatment"
android:icon="#drawable/ic_medicine"
android:title="#string/treatment" />
<item
android:id="#+id/nav_statistics"
android:icon="#drawable/ic_statistics"
android:title="#string/statistics" />
<item
android:id="#+id/nav_world"
android:icon="#drawable/ic_world_data"
android:title="World-wide Statistics" />
<item
android:id="#+id/nav_settings"
android:title="#string/settings" />
</group>
</menu>
all the icons that I am using are svgs and I imported them to android studio as vector assests.
what am I doing wrong here?
I'd like to move the horizontal separator that separates between different item groups in a navigation drawer and put it next to the titles of the group.
let's say I have the following XML:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:showIn="navigation_view">
<group android:checkableBehavior="single">
<item
android:id="#+id/mainFragment"
android:title="Principal" />
</group>
<item android:title="Second menu">
<menu>
<group android:checkableBehavior="single">
<item
android:id="#+id/listOption"
android:title="List" />
<item
android:id="#+id/favoriteOption"
android:title="Favorite" />
</group>
</menu>
</item>
</menu>
which has the following result
I would like to get a result where the separating line is next to "Second Menu" in way that it's positioned in the center. like this