I need a Vertical ListView where each row is a horizontal scrollable list of items.
Each items is an image with a button.
I need the app to be compatible with Android 2.2.
I've read 3 working solutions here
Use a custom Horizontal ListView as rows
Use a ViewPager as rows
ViewPager inside ListView
Use an horizontal ScrollView
These solutions are a bit old and each has their detractors.
So I was wondering, at the current state, is there an "official" solution for my problem?
Or, what is the best one?
If the no of items in the vertical ListView are fixed then you are better off using Horizontal ListViews for each.
Related
I have created a listview inside scrollview. Atfirst it was not scrolling but when it started scrolling then layouts below list view started disappearing from screen. is there any solution to dynamically calculated he height of list view and assign it or is it possible that some how the scrolling of listvew is disabled so that only its items appear on screen like normal layouts or any tags and it does not scrolls???
ListView is deprecated. I would suggest you to use RecyclerView and add nestedScrollingEnabled="true" to your xml or call RecyclerView.setNestedScrollEnabled(true) if you want to wrap adapterview with a scroller. You can also try NestedScrollView for support compability.
Good luck
I want Horizontal scrollable items in vertical recyclerView. horizontal items will not be more than 10 in any case.
I thought of two approaches
1) Horizontal Recyclerview as item in vertical RecyclerView
2) Custom horizontalScrollView as an item in vertical RecyclerView
I have implemented first one facing some issues in scrolling but I think I will manage that.
My question is, why not second approach. I have seen all related question on SO and most of them trying to do with first approach. Why is it so?
What is disadvantage? specially I you have limited number in horizontal view.
Any pointer would be great help.
Why do we use RecyclerView instead of LinearLayout?
Because if we use a LinearLayout consisting of (let's say 50 items) they will be all rendered on screen (50 Views) and this will lead to very very bad performance issues and scalability issues. RecyclerView does initialize the views that appears on screen only ,let's say 7 views, and they will be recycled in every new row that comes.
Why do we use Horizontal Recyclerview instead of Horizontal ScrollView?
This is not usually the case. If you have multiple items in every row that needs to be recycled then you should use Horizontal RecyclerView otherwise it won't matter at all.
To summarize,
The views in the vertical RecyclerView will got recycled whether it has another horizonal RecyclerView or Horizontal ScrollView, but the views inside the Horizontal ScrollView will not get recycled and the views inside the Horizontal RecyclerView will got recycled as it's a RecyclerView.
If you don't have multiple items in your Horizontal RecyclerView, you shall use Horizontal ScrollView instead.
I am looking for a way to do expandable listview horizontally. So basically, assuming you have a horizontal item, then when you click on it it expands to the right.
Any suggestions?
you cannot do a horizontal listview using the android api. There are a few external jars but i would not reley on them as they are no recent commits to their repositories.
But you can however do a horizonal scrollview and do your requirement in the onclick listener
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
Is it possible to allow a griview to scroll both vertically and horizontally simultaneously in android? Please advise.
It doubt that would be possible. A GridView is based on an ArrayAdapter, having only 1 dimension for the items. How would you arrange them in a view that can be extended both vertically and horizontally?
Of course, if you just want to make it larger than the screen and use hard-coded number of rows/columns, you can put it in another scrollable view.
There are following two solutions and you can use one which fits your requirement.
You can use RecyclerView instead of GridView with a custom layout manager. You can read this code for help. Also, you can read this article on how to create custom layout manager. This article gives an example of how to create two-way scrolling grid layout.
The other solution is to use RecyclerView with horizontal scrolling Grid Layout wrapped inside a scroll view.
<ScrollView>
<RecyclerView />
</ScrollView>
use GridLayoutManager with horizontal scroll for recycler view.
The first solution is efficient in a way that it handles view recycling properly.
Hope this will help.