I am using a NavigationDrawer in my application and I am loading in the drawer a ListView. When the drawer is opened, it covers almost half of an Activity which contains also a ListView.
The problem that I face is that if I tap on the drawer(not on an item contained in the drawer), a ListView item from my Activity gets the click event and then starts an activity associated with that list item.
Is it possible to restrict the clickable area of the drawer only to the list items?
I assume your drawer layout is more complex than just a simple ListView, if you have place to tap on the drawer.
In that case, you could simple specify
android:clickable="true" for your top drawer layout (LinearLayout, RelativeLayout or whatever you use).
Related
I'm facing an weird behaviour of navigation drawer so if someone can help...
I have a navigation drawer filled by an adapter (like list of Object : title and icon).
In Activity
mNavItems = NavBarUtil.listItem(); // List of object
mBinding.navList.setAdapter(new DrawerListAdapter(this, mNavItems));
The view for drawer is just a simple ListView.
The weird behaviour is that when the keyboard appears (whatever it comes), the order of the items in navigationDrawer change... it's like, displaying the keyboard recalculate all the view.
Just wanna precise that all listener for item work fine, the issue is just about the view like icon and title...
Thanks you guys
I have a sliding tab layout where i have 3 tabs and a navigation drawer. Each tab is a fragment. now i want to use one fragment as a cardview in a grid manner. but my problem is when i click navigation drawer item my tab fragment grid data is not changing.
here is the link of my code structure.
https://github.com/rrrongon/NavigationDrawerwithTab
Use event bus for achieve this. when you click on menu item fire an event and than listen that event to your respective fragment and on listen do your respective work
So I have set-up a navigation drawer and a main layout that downloads JSON data and displays it in a RecyclerView in a tab fragment.
Now what I intend to achieve is that, when I click on a hardcoded item in the navigation drawer it calls the API corresponding to it, should filter the main RecyclerView based on the JSON parameter passed.
(eg: If the Main Layout RecyclerView shows all the Items that you can buy, and the Navigation Drawer contains items like Laptops, Cellphones, TV, Clothing etc and while clicking on NavDrawer item, it filters the RecyclerView to show only the items in that particular category)
Why don't you have fragments for each navigation drawer item? These drawers will make the API calls and present the received information in the RecycleViews they hold?
It would be much easier and better than reuse a single view to present different information on different actions...
So I have already read from Navigation Drawer and from Creating a Navigation Drawer.
I am trying to have two or more different listviews.
Basically the scenario is the user to be able to click to 3 different buttons and have three different listviews. So I have two thoughts or I will create 3 listviews and with onClickListener I will open a different ListView or else a dynamic Listview that for every button to show a different listview but without changing the actual layout of the listview.
And I also have one sub question:
Is it possible to block the sliding navigation drawer from the sides? because I want him only to be able to open it from a button click. (I have already the code for button click, but I don't how to block the drawer from opening when I slide the side).
So any help??
I am getting a strage behaviour with my navigation drawer. I use a custom layout for it, containing not only the usual listview!
Whenever i click somehwere in the drawer section the rows from the behind listview are getting clicked. How can i disable that?
SOLUTION:
just set android:clickable="true" on the parent layout in the drawer outside the listview and it all works fine.
Thanks for your answers.
Try this in your MainAcivty with the drawer content when it's open, to disable sending touch events to parent layout
getParent().requestDisallowInterceptTouchEvent(true);
Set android:clickable="true" to the parent layout in the drawer section.