2012-02-15 26 views

答えて

5

ソリューションは、フッターの下部位置にリストビューの高さを比較することです。他人の利益のために

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(); 
     } 
    } 
} 

、フッタは基本的に私はaddFooterView経由ListViewに追加Viewです。 R.layout.footerはフッターのレイアウトです。以下は、私はフッターを初期化し、ListViewにこれを追加しまし方法についてはサンプルコードです:

View footer; //This is a global variable. 
.... 
//Inside onCreate or any method where you initialize your layouts 
footer = getLayoutInflater().inflate(R.layout.footer, null); 
listView.addFooterView(footer); 
+0

ここにフッタのコードを追加してください。 onCreateメソッドでフッターを初期化する方法は? – Jayesh

+0

@Jayesh:こんにちは!フッターをどのように初期化したかに関するコードを含めるように答えを更新しました。それが役に立てば幸い。 – Arci

+0

はい、それは私に有益です、ありがとう – Jayesh

0

私は(テストしていません)のようなものを試してみた:

if (listView.getScrollY() == listView.getMaxScrollAmount()) { 
    // ... 
} 
+0

ありがとう!私はonScroll()内でこれを試しましたが、listView.getScrollY()は常に0の値を返します。何が問題なのか知っていますか? – Arci

+0

Androidのどのバージョンをテストしていますか? OS自体のバグのように聞こえる。 – Felix

+0

私はAndroid API 8を使用しています。API 8のgetScrollYにバグはありますか? – Arci

関連する問題