Prevent ListView Scroll to top on notifyDAtaSetChanged - android

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.

Related

Android on scroll up stop autoscroll

I have to edit a ListView so that the autoscroll stop when I scroll up and restart when I scroll completely down as it works in Android Studio's window Logcat for example. How can I implement it?
The ListView is set with android: transcriptMode = "alwaysScroll".
implement OnScrollListener and look on the firstVisibleItem. Store it somewhere, then when onScroll is called again compare firstVisibleItem with what you got stored. If it's greater => The user is scrolling down otherwise the user is scrolling up.

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.

Android: ListView - state after scroll

I have a listview where I take control of the focus. When I reach the last visible position and click down the listview does not scroll. However, if I touch and scroll the listview then try to navigate the listview using my custom focus control, it works.
My question is what state does android put a listview in when the user touch and scrolls it?
I don't know what the problem was, but changing the Activity to a ListActivity solved the issue.

Android Scroll ListViewfrom code

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

Categories

Resources