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

12 關於 “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. grand canyon

    These coupons is found either offline through newspapers, entertainment directories and magazines, or
    online from the numerous discount coupon websites.

    The city offers a lot of professions and, if you’re searching to maneuver central, you probably be employed in the CBD or you desire
    work there. Owners may not approve of this; however, airline
    rules have to be followed to avoid delays and
    further problems.

    回覆

發表迴響

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