ViewPager items in a ListView not clickable - android

I have a ListView where each item contains a ViewPager (in a CardView, not sure if that matters). The desired behavior is that:
Clicks on the items work normally, as if the items were simple TextViews for example.
Swiping in the ViewPager works.
Right now, clicks on the ViewPager don't work. Clicking outside of the ViewPager does work as expected however, I had to set focusable="true" and focusableInTouchMode="true" for this to work. Other than that, there's nothing unusual in the code.

Related

RecyclerView: Nested clickable views

I have RecyclerView which has 2 Buttons inside its item and also swipable ViewPager. I need to set onClickListener for entire RecyclerView item but also allow to interact with ViewPager by swiping and those 2 Buttons.
Is this possible. I tried everything. Tried to set every single View to clickable false. Only Buttons and RecyclerView item parent is clickable. Also added to parent view android:descendantFocusability="afterDescendants" but none of this worked.
ViewPager is not clickable only swipable.
I couldn't solve this issue normally, but I solved it by little hack, I set onClickListener for each page of ViewPager and sent onClick function as parameter from RecyclerView item. This way clicking on page of the ViewPager will do the same as root in onBindViewHolder for its parent.
onClick listener is set inside custom ViewPagerAdapter right before I return layout to ViewPager in instantiateItem() function.
If I wanted to achieve onClick for entire item, I will probably never wanted to click on ViewPager item to perform other action. It would be bad design. Swiping ViewPager inside RecyclerView is not triggering onClick event so its fine.

ViewPager in ListView items

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.

Achieve ViewPager like effect for each row in a listview

I have an ListView activity where I have row of elements, & I need to achieve ViewPager like effect on swiping right or left.
I have heard that ViewPager cannot be used as rows inside a listview
Source: ViewPager inside ListView
So, how do I implement Viewpager like effects on swiping right or left on a row item in listview?
One hack I found was provided by Dallas Gutauckis
Link: http://dallasgutauckis.com/2013/04/30/android-putting-a-viewpager-inside-a-listview/

Listview in scrollable layout

Don't use listviews in scrollviews they say, well, okay, but how do you fix this?
I have a viewpager with some lists in it (mockup)
above that, I have a tabindicator and some other information that doesn't change when you go to another tab.
My problem is that I always want to scroll the complete view (so content, tabindicator and viewpager).
If you scroll down, only the fragment with the listview (=tab content) should be visible and scrollable.
I don't want to put the content view and tab headers in a listview header because I don't want them to change every time I go to another tab (swipey tabs, so the user will see it)
What's the best way to do this?

Adding a button bar at the bottom of ListView upon checkbox select (as in Gmail app)?

I have a ListView with custom adapter. In each row there is a checkbox and couple of textviews. I want user to give option to delete the check marked items, so as soon as soon clicks on one of the checkbox, I want a button bar to slide in from the bottom and stay at the bottom regardless of listview scroll. This is something like the email app behavior of Motorola Cliq and to some extent gmail app itself.
I have tried adding a relativelayout (containing buttons) below the listview, which has visibility set to gone initially, but as soon as user checks a button, the visibility changes to "visible". I have added a slide-in animation to it too. It is working but problem is that it is overlapping the last element of the listview which user can not checkmark if the button bar has already become visible. So I tried to set the bottom margin of the listview equal to the height of the button bar when I'm changing the button bar visibility, which solves the problem of overlap, but now the checkbox behavior has gone weird. Clicking on one checkmark tries to checkmark another checkmark in the list for some weird reason. I noticed that this happens because as soon as I change the listview margin, list redraws itself, and during this new call to getView() method of adapter, things mess up.
I wanted to ask if anyone has done something like this. What is the best method to add such button bar below list while keeping the slide-in animation intact. Also, What is the footer-view of listview and can that solve my problem?

Categories

Resources