Android Scroll ListViewfrom code - android

I'm trying to have a piece of code cause a ListViewto scroll. This is happening as another view is being scrolled. Currently I'm calling scrollBy(x,y) on this ListView to cause it to scroll. This causes the items in the list to scroll but does not cause new items to be loaded. I've tried calling invalidate on the list but this does not seem to work. The problem appears to be that what the list understands as visible items are only updated by touch events.
Does anyone know a way to get around this?

I think the problem is that ScrollBy and ScrollTo are methods of the base View, and thus seems to be scrolling the whole 'viewport' of the list.
If you want to scroll the items use smoothScrollBy or smoothScrollToPosition.
That should work

Related

Underscroll in RecyclerView android

I am creating a custom scroll inside RecyclerView and I did most of the work already but now I came to hopefully one of the last problems.
On scrolling, I am expanding/collapsing rows as they move up or down. It works fine until I reach the bottom of the list. Two items remain in their normal state because I can no longer scroll down and therefore they will not expand.
My question is, how can I scroll under the recyclerView when I reach the bottom? Do I need to implement onTouch listener and do the work from there? Or is there something in RecyclerView that can help me create the underscroll?
You should be able to expand them in onOverScrolled, as that will be called at the correct time to trigger their expansion.

SwipeRefreshLayout and ListView action detection

So I'm currently working on a bit not-ideal legacy Android project and I'm trying to solve this inconsistency regarding SwipeRefreshLayout and ListView. Both of these views are added programmatically as follows:
// lv is ListView initiated elsewhere.
mSwipeRefreshLayout = new SwipeRefreshLayout(this);
mSwipeRefreshLayout.addView(lv);
Pull-to-refresh and anything related to SwipeRefreshLayout and ListView actions are working as expected. But, if I'm scrolling with intention to trigger pull-to-refresh mechanism:
On portrait, my ListView fires up onScroll but NOT through onScrollStateChanged whereas if I'm scrolling up (moving ListView contents up) I get the expected event sequence from ListView.
On landscape, I didn't receive any scroll event on the ListView unless I'm scrolling up (moving ListView contents up) which is what I wanted.
Does anyone have an idea or a pointer for me to start looking for the solution? I figured that somewhere, some code part triggered a scroll but I've been at it for almost a day now and cannot find it and started to think that I might be barking on a wrong tree.
Thank you.

ListView with ViewPagers

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

Prevent ListView Scroll to top on notifyDAtaSetChanged

I'm using a listView that gets notifyDataSetChanged() called every few seconds and if user is scrolling down, he's automatically scrolled to top.
What could be the reason?
I've not used any .setSelection(0), or other methods that force scrolling. What could I be doing wrong?
Used CursorAdapter to populate listview, problem went away.

Weird list behavior in android

I have an ImageView on top of a ListView and whenever there is a long running process to populate the list I would like to hide the ListView and make the ImageView visible.
I tried some things with setVisibility() but I'm getting messed up scroll behavior for the list.
I'm using AsyncTask to manage all this but I don't think that's causing the messed up scrolling behavior. Any ideas on how I can display a busy spinner while the list is being populated and not get inconsistent scrolling behavior for the list?
As far as the weird scrolling behavior you may need to set this property on your listview android:cacheColorHint to #00000000
Otherwise it will do weird things when there is an image under the ListView while scrolling.

Categories

Resources