smoothScrollToPosition after notifyDataSetChanged not working in android

前端 未结 2 490
轻奢々
轻奢々 2020-12-05 05:05

I\'ve got a custom Adapter for a ListView setup and working ok. On a button click something is changed in the underlying data, so a notifyDataSetChanged is required to refre

2条回答
  •  盖世英雄少女心
    2020-12-05 05:17

    I've tried the dmon's example code and I see it not always working.

    Actually I've found another approach to perform scrolling:

    adapter.notifyDataSetChanged();
    channelsListView.setSelection(scrollPos); // it works without smoothScrollToPositionFromTop(..) or smoothScrollToPosition() methods call.
    

    I found the main idea to use above method after this answer reading: https://stackoverflow.com/a/20997828/2133585

提交回复
热议问题