Android listView偵測現在滑到什麼位置

希望 ListView 捲動時

捲到第一列消失後
就要執行某個動作

下面可以達成需求


list.setOnScrollListener(listScrollListener);

private OnScrollListener listScrollListener = new ListView.OnScrollListener(){
@Override
public void onScroll(AbsListView arg0,
int firstVisibleItem, int visibleItemCount, int totalItemCount) {
if (totalItemCount <= 0){ return; } if (firstVisibleItem == 0) { //目前第一列還在畫面上 } else { //第一列已經消失在畫面上,在這執行要做的動作 } if (firstVisibleItem + visibleItemCount >= totalItemCount){
//表示最後一列已經出現在畫面上了
//到底了
}
}

@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
}
};

15 關於 “Android listView偵測現在滑到什麼位置” 的評論

  1. AdultFrienedFinder login

    Hmm it appears like your blog ate my first comment (it was extremely long) so I guess I’ll just sum it up what I had written and say, I’m thoroughly enjoying your blog.
    I as well am an aspiring blog blogger but I’m still new to everything.
    Do you have any tips and hints for rookie blog writers?

    I’d genuinely appreciate it.

    回覆
  2. Lola Wilson

    Thanks for sharing your impressive and amazing tips.
    I will not be reluctant to share your website
    to any person who should receive suggestions just
    like these.

    回覆
  3. Erotik

    I think this is one of the most important information for me.
    And i’m glad reading your article. But should remark on few general things,
    The web site style is perfect, the articles is really excellent :
    D. Good job, cheers

    回覆
  4. Dominic

    I desired to thank you a lot more for this incredible website you have made here.
    It is truly is packed with beneficial tips for all those who are genuinely enthusiastic about this subject, particularly this very post.

    回覆
  5. Link Alternatif Sbobet

    I blog often and I truly appreciate your content. The
    article has really peaked my interest. I will bookmark your website and keep checking for new information about
    once per week. I opted in for your RSS feed too.

    回覆
  6. digital pianos

    I’m really inspired togethr wiith your writing talents as
    smartly as with the structure for your blog. Is tjis a paid topic or did you modify it your self?Anyway keep up the nice high quality writing, it is rarfe to peer a great blog likme this one today.

    回覆

發表迴響

你的電子郵件位址並不會被公開。 必要欄位標記為 *