Add imageview and texview for each menu item in Navigation Drawer - android

I want to add an imageview and texview in each item of navigation drawer (like a cart image(Imageview) and items added in cart(Textview))

This thing known as badge view
Library Link

You can implement it using RecyclerView. Take a look at these series of tutorial:
https://www.youtube.com/watch?v=Wq2o4EbM74k

Lets first define titles and icons of the navigation drawer . So open your projects strings.xml file and add two string arrays .
After that we design xml of item of the navigation drawer. This layout is inflated every time we add a new item in the navigation drawer .
check this link i hope is usefull for you:https://androidbelieve.com/material-navigation-drawer-with-header/

Got the solution, just needed to add app:actionLayout in each of my menuItem and pass the layout in it.
And you can instantiate each of the widgets using
navigationView.getMenu().findItem(menuitemId).getActionView().findViewById(widgetId)

Related

Android - Changing item title in bottom navigation bar

I have 2 fragments between which I can navigate with a bottom navigation bar. I also have an overflow menu with an item which shows an edittext dialog.
I want that when I write and validate text in the dialog, the currently displayed fragment's item on the nav bar changes of title. I don't know how to change text of a specific item.
I hope my question is understandable. I have been searching through SO but I didn't find any corresponding answers.
In Kotlin
bottom_nav_view.menu.findItem(R.id.bottom_nav_item).title = "TITTLE"
in Java
bottom_nav_view.getMenu().findItem(R.id.bottom_nav_item).setTitle( "TITTLE")
If you define an id for the item you want to change in the layouts menu (add the line android:id="#+id/myid"), you can find that item in the code by using findViewById (R.id.myid). Then, just set the new the title depending on what the item is.
Without any code I can only guess that you setup a ViewPager with the TabLayout method yourTabLayout.setupWithViewPager(yourViewPagerAdapter);.
If it is so, you can simply set a title using
yourTabLayout.getTabAt(position).setText(yourTitle); where position is 0 for first tab and 1 for second tab.
If you post some code I can try to specify my answer on your code and the way you are adding the fragments to your activity.

View switching between MaterialDrawer layouts

I need to create two MaterialDrawer for the same activity and switch between them. But I need that items be updated when the Drawer is being displayed on the screen.
With the properties we have for MaterialDrawer, the changes between one drawer layout to other only can be visible after the drawer is closed and you touch the drawer toggle again.
Is it possible to do a refresh in the layout, do a invalidate or do a notify in the changes during the display of the drawer, when switching between drawers, for the changes to be displayed on the fly?
Thank you,
Alexandre Bianchi
The MaterialDrawer comes with a easy to use API which will allow you to modify the items, shown in the Drawer at runtime, without the requirement of creating a new Drawer object.
You can remove the current items in the list at any time via the removeAllItems method. https://github.com/mikepenz/MaterialDrawer/blob/develop/library/src/main/java/com/mikepenz/materialdrawer/Drawer.java#L747
And you can easily add new items in the same style via the addItems method: https://github.com/mikepenz/MaterialDrawer/blob/develop/library/src/main/java/com/mikepenz/materialdrawer/Drawer.java#L756
These changes will directly reflect in the UI.
For some more complex usecases you can also look into the source code used for the AccountSwitcher which will switch 2 lists in the Drawer and animate them: https://github.com/mikepenz/MaterialDrawer/blob/develop/library/src/main/java/com/mikepenz/materialdrawer/AccountHeaderBuilder.java#L1348

How to add grid-view into tab layout in Android

I want to have a grid view menu or pop up menu that drop or slid with a button.not a Drawer layout.something like giddylizer app this:
giddylizer app image
is there any library?any helpful links and suggest...
As a suggestion , you can achieve that design easily by
Add frame layout into your main layout
Create two tabs with two fragments
Add grid-view into fragments
done.

How can I make a multi-level(more than 3 level) navigation drawer in android?

I am developing an android application where I need to put a navigation drawer which would have more than 3 levels.
What I want to do: If I click one item of my list in the drawer, a whole new list comes up in the drawer. This new list should also do the same when items of this list are clicked. This could go on for many levels.
What I have done till now: I am keeping an expandable list which expands when I click on any item. This design doesn't allow adding more levels.
Application which have similar drawers: svpply (please have a look at this application, it has a similar drawer)
I am a newbie in android development, try to add details to your ideas.
Thanks!
Have a single drawer keeping a FrameLayout.
Make all your list as ListFragment
Make Fragment Transaction on FrameLayout when a item is clicked.

Changing navigation drawer layouts

How to inflate new layout on custom navigation drawer when, for example, I click another button in main activity? Is that possible? I havent found any function like beforeOpenDrawer or etc. Or should I construct 4 seperate drawers?
Thank you for your answers
We managed that using fragments. Our DrawerLayout contains a FrameLayout in which we put a "menu" fragment. Some clicks replaces the "menu" fragment by a "submenu" fragment.
I'm not sure I get what you mean.. but if what you want is:
. To create a navigation drawer with custom layout (not just list view) then it is possible.
. Or if you having multiple buttons or radio buttons inside the drawer layout and you need for example to listen for their onClick events … you only write the code once inside the main activity that inflate the left or right drawer.. I've tried something like that but I was using fragments not activities.

Categories

Resources