2013-04-28 70 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()將不工作,你可以試試你的聽衆之外的這個方法,使用偵聽器中的值...