ListView entry in list after scrolling

How can I detect an element listViewto change or do some action when it scrolls over the center screen?

UPD Solution

    @Override
    public void onScroll(AbsListView view, int firstVisibleItem,
            int visibleItemCount, int totalItemCount) {

        int half = visibleItemCount/2;
        int to = firstVisibleItem+half;

        for (int i=firstVisibleItem; i<to; i++) {
                          // actions for item above center 
            Item item = (Item)adapter.getItem(i);
            item.read = true;
        }
        adapter.notifyDataSetChanged();
    }
+3
source share
2 answers

You can set ListView.OnScrollListener and check if the item you want to scroll over the center is required. The onScroll method will provide you with the number of visible elements, the index of the first and the general elements of your list, knowing this, you can determine when the element scrolls over the position.

+1
source

, . ListView (.. ​​ MATCH_PARENT), /2. getChildCount() .

, ListView.OnScrollListener ListView.

ListView , , :

 DisplayMetrics metrics = getResources().getDisplayMetrics();
 int windowWidth = metrics.widthPixels;
 int windowHeight = metrics.heightPixels
+2

All Articles