• 判断最后listView中最后一个item是否完全显示出来


     /**
         * 判断最后listView中最后一个item是否完全显示出来
         * listView 是集合的那个ListView
         * @return true完全显示出来,否则false
         */
        
        protected boolean isLastItemVisible() {
            final Adapter adapter1 = listView.getAdapter();
    
            if (null == adapter || adapter.isEmpty()) {
                return true;
            }
    
            final int lastItemPosition = adapter.getCount() - 1;
            final int lastVisiblePosition = listView.getLastVisiblePosition();
    
            /**
             * This check should really just be: lastVisiblePosition == lastItemPosition, but ListView
             * internally uses a FooterView which messes the positions up. For me we'll just subtract
             * one to account for it and rely on the inner condition which checks getBottom().
             */
            if (lastVisiblePosition >= lastItemPosition - 1) {
                final int childIndex = lastVisiblePosition - listView.getFirstVisiblePosition();
                final int childCount = listView.getChildCount();
                final int index = Math.min(childIndex, childCount - 1);
                final View lastVisibleChild = listView.getChildAt(index);
                if (lastVisibleChild != null) {
                    return lastVisibleChild.getBottom() <= listView.getBottom();
                }
            }
    
            return false;
        }
  • 相关阅读:
    5.1、字符串插入
    2.2、部署 Discuz!
    7.1.5、测试数组
    4.2、php 注释
    5.2、操作符
    2.3、初始化 Discuz!
    5.3、控制结构
    gradle 又一项目构建工具
    1.1、概述
    7.1.8、通过追加数组的方式创建数组
  • 原文地址:https://www.cnblogs.com/jss4j/p/4311602.html
Copyright © 2020-2023  润新知