I implemented ViewPager in ListView items. In general works perfect, but have some issue.
When I scroll ListView and then touch on screen (during scrolling list) in this case I can't scroll ViewPager in this item, ListView has focus. I should select it again for ability to swipe. ListView has returned SCROLL_STATE_TOUCH_SCROLL state, when I touch it during the scroll. At this moment I should focused on ViewPager for ability to swipe items.
Can I solve this issue without any scroll conflicts in ListView and ViewPager? I guess that it's imposible, but, decided to ask here.
Or, maybe you can advice me to use some other control to implementing swipe in ListView items. But scroll animation should be the same as on ViewPager.
Thanks for any advice.
Depending on your XML, you end up with needing to implement OnTouchListener. If the view you want to handle the event can handle it, then return true, if not false. Then the parent can handle it. You might also want to look at ViewGroups, particularly the onInterceptTouchEvent.
Related
I have a listView, with a footer attached to it, which is Button. This Button works fine when there is no Scrolling involved.
When the listView is scrolling, it becomes unclickable, like the other items in the ListView. Since it takes some time after the View have reached bottom, and the View actually stops "Scrolling", the footer(Button) is unclickable for a sec or 2. Is it possible to make an item, in this case a ListView footer, clickable while the ListView is scrolling? Or another clever solution to this issue?
try to make the button.setClickable(true). it should be clickable during the scrolling
This sounds like another one of a very long list of problems with ListView stealing touch events from its child views. The solution is to use RecyclerView instead. ListView is essentially deprecated and RecyclerView is the replacement.
Simple question - how to disable recyclerview scrolling while swiping its item? I created OnTouchListener inside recyclerView item view holder, but it catches swipe events only if user makes straight horizontal line. Otherwise recycler list is scrolling. Any ideas?
I am not using ItemTouchHelper because it doesnt quite do what I want. I solved this by checking the source to it and finding the call to:
getParent().requestDisallowInterceptTouchEvent(true)
Call that when you determine the user has started swiping (i.e., moved more than a few pixels). Then don't forget it to call it again with false when the swipe is done.
I'm facing the opposite problem. If you are using the ItemTouchHelper, do this
mItemTouchHelper.startSwipe(myViewHolder);
This would force the swipe instead of the scroll.
I need my ViewPager to act like ListView, I mean if you start scrolling and took finger off listview proceed scrolling for some time. Maybe, somehow You know how to implement this in ViewPager?
Maybe you should try HorizontalScrollView?
http://developer.android.com/reference/android/widget/HorizontalScrollView.html
Im having trouble with my UI.
It contains a ListView , with ViewPagers as List Items.
The problem is that the horizontal scrolls seem to get interrupted by the ListView (catching vertical scrolls).
What i want to achieve is that no matter what happens, the horizontal scrolls finish all the time. Right now they stop half way sometime.
this is probably a common problem, but i havent found a solution yet.
I've tried to intercept horizontal scrolls on the the listview, but although I can intercept, it still causes the swipe to stop.
can anyone point me in the right direction ?
ViewPagers are not compatible with ListViews.
Sorry.
ViewPager inside ListView
I have a ViewPager widget in every row of a ListView. This provides a shelf-like UI, so the user can scroll around searching for a shelf vertically, and then scroll horizontally amongst the contents of a shelf. This works.
But the scrolling experience is terrible: if I start to drag a shelf's ViewPager, scroll it horizontally, and accidentally drag a bit upwards/downwards, then the ListView "traps" this dragging action, and start to scroll vertically, ending my horizontal drag. In this state, the drag action won't "return" to the ViewPager, the ListView has it, and that's it. I have to start another drag action to affect the ViewPager again. So I guess the ListView has precedence in these cases.
How can this be fixed? I'd like to achieve the exact opposite: If the ViewPager inside a list row starts reacting to a horizontal drag, then it should trap that action, and this drag should stop affecting the ListView, no matter how the user moves his/her finger vertically. Can this be done?
I've found a solution in this thread. There the problem is to handle touch events properly for a HorizontalScrollView inside a regular ScrollView, but the solution to that problem seems to apply to this one too.