Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find out if ListView has scrolled to top Most position?

Tags:

android

I have a ListView, first its scrolled down, now when we scroll up,it reach top most point. I want to detect that .Is there any way?I am developing application with api level 8.Pls help..

like image 773
ShineDown Avatar asked Sep 06 '11 10:09

ShineDown


People also ask

How do I make ListView scroll smoothly?

The key to a smoothly scrolling ListView is to keep the application's main thread (the UI thread) free from heavy processing. Ensure you do any disk access, network access, or SQL access in a separate thread. To test the status of your app, you can enable StrictMode .

How do I listen to scroll position in flutter?

I used NotificationListener that is a widget that listens for notifications bubbling up the tree. Then use ScrollEndNotification , which indicates that scrolling has stopped. For scroll position I used _scrollController that type is ScrollController .

Does ListView have scroll?

Listview so have inbuild scrolling capabilities. So you can not use listview inside scrollview.

What does list view do?

A list view is an adapter view that does not know the details, such as type and contents, of the views it contains. Instead list view requests views on demand from a ListAdapter as needed, such as to display new views as the user scrolls up or down. In order to display items in the list, call setAdapter(android.


1 Answers

edit

See comments below as to why, especially on different API versions (esp later ones), this isn't a foolproof way to see if you're list is at the top (padding etc). However, it does give you a start for a solution on devices below API 14:

private boolean listIsAtTop()   {        if(listView.getChildCount() == 0) return true;     return listView.getChildAt(0).getTop() == 0; } 

As far as my implementation years ago - this worked perfectly at the time.

like image 92
Graeme Avatar answered Sep 25 '22 12:09

Graeme