2013-04-28 45 views
0

我有这个代码,我得到了与getChildCount()和最后一行上的2错误。检查底部是否达到滚动视图的方法

protected void onScrollChanged(int l, int t, int oldl, int oldt) 
{ 
     // Grab the last child placed in the ScrollView, we need it to determinate the bottom position. 
     View view = (View) getChildAt(getChildCount()-1); 

     // Calculate the scrolldiff 
     int diff = (view.getBottom()-(view.getHeight()+view.getScrollY())); 

     // if diff is zero, then the bottom has been reached 
     if(diff == 0) 
     { 
       // notify that we have reached the bottom 
       Log.d("Hier", "MyScrollView: Bottom has been reached"); 
     } 
     super.onScrollChanged(l, t, oldl, oldt); 
} 
+0

'scrollview.getChildCount() - 1'我在getChildAt(..) – jamalM 2013-04-28 18:53:40

回答

0

总体上滚动改变了ListView的工作..

如您在列表视图

的听众打电话

所以GetChildView()将不工作,你可以试试你的听众之外的这个方法,使用侦听器中的值...