如何通过代码在一段时间后动态滚动我的列表?

发布于 2025-01-01 21:22:27 字数 424 浏览 5 评论 0原文

我有一个由 SimpleAdapter 填充的 ListView。简单的适配器填充使用 哈希映射。

列表中的每个 TextView 都显示歌曲的歌词。假设当前有 2 项列表 完全可见,第三个半可见半隐藏,如下所示: 在此处输入图像描述

我正在使用 MediaPlayer 播放歌曲。当第二首歌曲播放结束时,我需要滚动列表 这样列表的第三项(由于屏幕分辨率而被一半隐藏)可以出现在顶部 如下: 在此处输入图像描述

我想在 mediaPlayer 处于 PlaybackCompleted 状态(即第二首歌曲结束时)时实现此场景。我应该怎么做?我对android还是比较了解,请指导我!

I have a ListView which is populated by SimpleAdapter. Simple adapter is stuffed using
HashMap.

Each TextView in the List shows lyrics of a song. Suppose at current time 2 items of list
are fully visible and 3rd is half visible and half hidden as follows:
enter image description here

I am using MediaPlayer to play songs. When 2nd song playback ends, I need to scroll the list
so that 3rd item of list (which is half hidden due to screen resolution) could come on top
as below:
enter image description here

I want to implement this scenario whe mediaPlayer is on PlaybackCompleted state i.e. when 2nd song is ended. How should i do this? I am still a bigner in android please guide me!

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

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

发布评论

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

评论(1

随遇而安 2025-01-08 21:22:27

阅读文档后,我知道 ListView.smoothScrollToPosition(intposition) 或 ListView.setSelection(intposition) 方法将满足这种情况。

After reading the documentation i have come to know that ListView.smoothScrollToPosition(int position) or ListView.setSelection(int position) methods will fulfill this scenario.

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