Enable viewPager single click inside listview? - android

I am using view pager inside listview for swiping multiple images. Swipe are working fine but single click on view pager are disabled because i have used another image layout for showing image in view pager.

Try adding the following attribute in the parent layout of your list item:
android:descendantFocusability="blocksDescendants"

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.

Android list view inside a scroll view auto scroll issue

I have an android layout setup where I have a ScrollView with some elements and inside that I have a ListView. I am using StackOverflow's answer Android list view inside a scroll view for achieving this feature and it's working fine. My ListView is below some elements like TextView, ImageView. Problem is that when the page is presented ListView get scrolled automatically so that first item in listView is at the top (ie whole scrollview gets scrolled to present listview first item). How can I avoid this auto scrolling?
Add android:descendantFocusability="blocksDescendants" to child of SrollView (and parent of ListView)

Not scrollable listview in scroll view android

i need to make a layout that is scrollable, holds a listview that is not scrollable(full height of the content). So when i scroll the content above the listview is showed, and the full listview is displayed.
Is this possible in android?
what do you mean by ListView ( not scrollable).. will it have predefined items(count) ?
you can have a <ScrollView></ScrollView> inside of which a normal(linear/relative layout say id insidelayout1)
For single item of your ListView, create a separate xml(say item.xml) and try to inflate item.xml into insideLayout1.
Will that work for you.. or detail out your requirement...
If you want to put list view inside the scroll view than you have to fix the height of list view.
otherwise you can't scroll it properly.

How to add dots for ViewPager in Android?

I am referring to the following link to create a view Pager for android 2.2
ViewPager Example Link
It worked all fine. But I want show dots below the views I am using. How do I do this?
I am not writing any code here as its same as the one in the link I have shared.
When you are put view inside view pager and view contains dots then you can see dots below views.This is not the part of view pager and view pager is only display views whatever you are provided onInstantiate method called .You can put textview below your exist view and given this view same before to view pager

Merging ViewFlipper with ListView

What I'm trying to do is to have horizontal ViewFlipper and Listview, both with custom ArrayAdapters, inside LinearLayout which would be vertically scrollable on whole screen.
1) Tried adding ViewFlipper as a ListView header but then I can't use GestureListener since ArrayAdapter takes control over it like it's ListView item.
2) Tried putting them together inside LinearLayout but ViewFlipper's position is fixed and ListView is scrollable inside rest of the screen.
3) Trying with MergeAdapter but it can't handle swipe gesture on it's first element (ViewFlipper), it always returns ViewFlipper's item position.
Here's the picture to clarify what I'm trying to make. Top Stories is ViewFlipper and Latest Posts is ListView. And they both scroll vertically. Ignore bottom tabs and ActionBar as they are static (nonscrollable).
You've got your work cut out for you.
Here are two approaches:
1) Set the view flipper as the first row in the List view. Its a special case. Not as a header, but as a regular row.
2) Use a scroll view, and do not use the list view at all. You may have performance problems if your data for the list view is a large number of items.
Take a look at the ViewPager from the Android Compatibility Library it does what you need

Categories

Resources