android – 如何知道ListView的最后一行是否完全显示?

android – 如何知道ListView的最后一行是否完全显示?,第1张

概述我知道如何检查ListView的最后一行是否可见.但是,可见并不能保证行完全显示.如何检查最后一行是否完整显示? 解决方案是将ListView的高度与页脚的底部位置进行比较. public void onScroll(AbsListView arg0, int arg1, int arg2, int arg3){ if(arg1 + arg2 == arg3) //If last row 我知道如何检查ListVIEw的最后一行是否可见.但是,可见并不能保证行完全显示.如何检查最后一行是否完整显示?解决方法 解决方案是将ListVIEw的高度与页脚的底部位置进行比较.

public voID onScroll(AbsListVIEw arg0,int arg1,int arg2,int arg3){    if(arg1 + arg2 == arg3) //If last row is visible. In this case,the last row is the footer.    {        if(footer != null) //footer is a variable referencing the footer vIEw of the ListVIEw. You need to initialize this onCreate        {            if(ListVIEw.getHeight() == footer.getBottom()) //Check if the whole footer is visible.                doThisMethod();        }    }}

为了他人的兴趣,页脚基本上是一个VIEw,我通过addFooterVIEw添加到ListVIEw. R.layout.footer是页脚的布局.下面是我如何初始化页脚并将其添加到ListVIEw上的示例代码:

VIEw footer; //This is a global variable.....//InsIDe onCreate or any method where you initialize your layoutsfooter = getLayoutInflater().inflate(R.layout.footer,null);ListVIEw.addFooterVIEw(footer);
总结

以上是内存溢出为你收集整理的android – 如何知道ListView的最后一行是否完全显示?全部内容,希望文章能够帮你解决android – 如何知道ListView的最后一行是否完全显示?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1128959.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存