zoukankan      html  css  js  c++  java
  • 判断最后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;
        }
  • 相关阅读:
    共享经济
    滑动用hammer
    js 数组去重 的5种方法
    js ajax上传图片到服务器
    js url图片转bese64
    去除移动端 a标签 点击有一个 阴影效果
    css 文字超出变 ... 点点点
    h5手势库 hammer.js
    xshell linux传文件
    IO流(Properties存取)
  • 原文地址:https://www.cnblogs.com/jss4j/p/4311602.html
Copyright © 2011-2022 走看看