开发者

How to turn list scrolling off when calling onContentChanged in Android ListActivity?

I got a Lis开发者_运维技巧tActivity.

I update the activity using onContentChanged() API.

My problem is that each time I call the above API the list scrolls to the top. Is there any easy way to turn this "feature" off?

Thanks.

/ Henrik


Activity#onContentChanged is not for 'updating' the data for the activity. It is called when the content view of the activity changes, i.e., when Activity#setContentView is called. The ListActivity will reinitialize it's content view when it receives onContentChanged.

The answer is, you're doing it wrong, don't use onContentChanged the way you are using it. That is why you are seeing this unexpected behavior. Use another method to update the ListView, most probably by calling notifyDataSetChanged from your Adapter.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜