系统什么时候调用adapter的getview函数

发布于 2024-12-01 06:26:41 字数 92 浏览 2 评论 0原文

我想知道何时调用 getView 函数,如果我想刷新列表视图,但不知道该怎么做。比如,listView 中显示了 7 个项目,现在,我想将其更改为其他 7 个日期和图像。

I want to know when the getView function will be called, case I want to refresh the listview, and don't know how to do. something like, there are 7 items shown in a listView , and now , I want to change it to 7 other date and images.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

生死何惧 2024-12-08 06:26:41

如果您需要以编程方式滚动视图,可以使用 smoothScrollToPosition 但仅在 API 8 及更高版本中支持。

If you need scroll view programmatically, you can use smoothScrollToPosition but it supported only in API 8 and higher.

难理解 2024-12-08 06:26:41

要刷新列表视图,

Adapter.NotifyDataSetChanged()

请调用编辑

通常列表视图的列表项将具有相同的高度,如果您可以计算高度并调用,

ListView.scrollBy(x, y);

即使很简单,

ListView.smoothScrollToPosition(position); 

如果您知道

列表视图应呈现您在列表中添加的新项目的 位置,您也可以调用适配器(前提是您调用了notifydatasetchanged())

to refresh the listview call

Adapter.NotifyDataSetChanged()

EDIT

generally listview's list item will have same height if you can calculate the height and call

ListView.scrollBy(x, y);

even simple you can call

ListView.smoothScrollToPosition(position); 

if you know the position

the listview should render the new items you added in the adapter(provided you call the notifydatasetchanged())

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文