开发者

ListView "onPopulate" Listener?

I want to set an initial scrolled position to a ListView.

I thought I could do that by calling list.setSelectionFromTop after adapter.notifyDataSetInvalidated, but of course the later only notifies the listview and the actual populatio开发者_运维技巧n may happen later.

Is there a way be notified when the listview has populated itself, so I can change the scroll?


Ok, so I tried onFinishInflate and onSizeChanged, but they didn't work. The later worked if the number if items changed, but not if the data was simply altered.

I then tried everything else, and the working methods to override were onFinishInflate and onSizeChanged. These are however also called on scrolling.

In fact, the last line in ListViews layoutChildren is a call to invokeOnItemScrollListener, so it turns out you don't have to extend ListView, but can simply set an onScrollListener.

No matter what solution you choose, you do however need to manually work around the problem of methods being called on scroll.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜