ListView的刷新取到列表顶部 [英] ListView refresh taking it to the top of the list

查看:232
本文介绍了ListView的刷新取到列表顶部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

场景:我使用的自定义适配器列表视图。我取每5秒内的数据,然后在列表视图中显示它。

问题:每一个后刷新顶部的列表滚动。我希望该列表保持原样从滚动的立场和公正的基础数据被刷新。

当前code:这就是所谓的我每次获取新的数据时

  mListAdapter =新CustomListAdapter(这一点,mListData);
mList.setAdapter(mListAdapter);


解决方案
而不是你的code的

请尽量把每次获取数据时这一个:

  adapter.notifyDataSetChanged();

Scenario: I am using a listview with custom Adapter. I am fetching data every 5 seconds and then displaying it in the listview.

Problem: After every refresh the list scrolls at the top. I would want the list to stay as is from the scroll standpoint and just the underlying data to be refreshed.

Current code: This is called every time I fetch a new data.

mListAdapter = new CustomListAdapter(this, mListData);
mList.setAdapter(mListAdapter);

解决方案

Instead of your code please try to put every time you fetch data this one:

adapter.notifyDataSetChanged();

这篇关于ListView的刷新取到列表顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆