how to display listview's scroll item by item - android

i want to display the listview's scroll item by item, means single item height is equal to listview height, so on listview there is only one item will display at a time, and after scrolling the listview, remaining item will display. But problem is that if i scroll listview, it scroll many items, but i need to scroll only by one item.
in-short listview scroll by many row at a time but i want only one row scroll at a time
please suggest me some tips or method :)
thank you

So if I understand you correctly, you want a 'pager', sort of like, you scroll page per page instead of inbetween every item, right?
I'm using a Horizontal Pager at the moment, it uses a GroupView and measures the scroll amount to snap to the next view in the pager. Perhaps you could write your own GroupView as well calculating the scroll Y values to snap to the next page..
It's not going to be easy, but it's the only way I can think of.
You could look up Horizontal Pager on google and look at the code, and implement it for vertical paging :)

Related

Vertical ViewPagers(kind of) thing using a list(recyclerview or listview)

What I want to achieve is that when the list is populated in recyclerview, every list item when scrolled up or down should be displayed as one item in the list only(covering whole of the space provided for the recyclerview). In other word, lets say that each list item should match the height and width of recyclerview. When the list is scrolled all the big listitems can be seen scolling but when scrolling ends only one view is displayed.
If still not clear, I just want a recyclerview to show only one item at a time and if we want to see other list items we have to scroll.
Similar to what a view pager but vertical in direction and should be using a recyclerview.

Complex RecyclerView

I want to achieve a specific pattern with a RecyclerView list by displaying a dynamic contact list based only on a single CardView.
The contact list can have several items in it. Like over 100. Every contact should be a single item and of course, all the area should be scrollable.
A solution would be to make a non-scrollabe ListView but the scroll would not be fluid as there are many items in the list.
Another solution would be to create a custom CardView item for the top, the middle and the bottom or even overlap all the CardView items with a negative margin.
I am wondering if there are some better solutions working with the RecyclerView?
I would try to use a nested recycler and intercept (steal) touch events with the child in the area it's in.

Closed or circular Horizontal ListView Android

I have an Horizontal listview i want listview should be closed. For example if the last item is reached in Listview then show the first item below the last item. It means item should be in circular format. And if i scroll from first item it should show last item before first item. I want scrolling for both side.
Below image can tell u what exactly i want
In the First image it is showing 5 items and when scroll the Listview it should scroll the items As shown in Second image Thanks In Advance.
As per your requirement you want circular/infinite scrolling horizontal list view,
This is InfiniteScrollView which may help.You need to update this library as per your requirement and change ImageView to any other view which you want to scroll horizontally.
Edit - Solution below works for scrolling list view circularly only on one side ::
Check this circular-list for implementing a circular list adapter. And as your list view is horizontal check this library to create a custom horizontal list view.
Happy Coding :)

Does ListView expect the selected row from setSelection() to be on the top when a user scrolls?

I have a ListView which has overlayed on top of it another view which I call a Header. This header can be of various heights.
On ListView's dataset, I insert in a blank row, and programmatically set the height of this row to be the height of my Header view. This way when the ListView loads, the row at position 1 (the actual first row of data) is lined up to the bottom of the header. I do this so I can set the Header view as partially transparent and when the user scrolls they see the rows of data mix with the transparency of the Header view.
Now I have one use case where I can navigate to this list and a given row will be selected. What I've done is call setSelection with position X. This will automatically scroll my ListView so that the top of row X is at the top of the list. However, my Header view still obscures this. To compensate I call scrollTo. These two pieces are something as such:
listView.setSelection(selectedRowPosition);
if(hasHeadersEnabled()) {
listView.scrollTo(-headerView.getMeasuredHeight).
}
When I call these lines of code, my ListView looks as I would expect. The selected row's top is to the bottom of my HeaderView. The problem I run into is that as soon as a user touches the ListView, the scroll position jumps so that the selected row's top is at the true top of the ListView (aka the Header view's top).
My question is, after you setSelectedRow on a ListView, does the ListView always expect that row's top to be the ListView's top when it starts consuming the onTouch events for scrolling? Is there another way to accomplish what I'm hoping to do with this code? I've tried scrollTo and scrollBy and both have the same effect.
So I should have looked at the API harder. Found the answer to my question.
I need to use setSelectionFromTop instead of the combination of setSelection and scrollTo. Here is the sample code:
listView.setSelectionFromTop(rowPosition, headerView.getMeasuredHeight());

Memory efficient list for android

I have a list of about 100 items. In each list item I need a framelayout with 2 relative layouts. When a button called "Flip" is clicked then one relative layout will flip out and the other relative layout will flip in. And each item has full width of the screen. So, I need to show the item in a horizontal scroll view. Now, I want to keep at most 3 items every moment. When user scrolls to the first item then we have to update the 3 items. The first item will be the 2nd item. And we have to add another item at the front. In this way we have to update the items when user scrolls to the last item. I have tried many ways. I have used Gallery for the horizontal scroll view. And used the onItemSelected method. But, if I scroll the Gallery fast then it crashes. So, please someone help me to implement the 3 items idea.
It sounds like you need a ListView. Is there a reason you are trying to reinvent it?
Also don't you mean a vertical scroll view? Why are using a horizontal?

Categories

Resources