如何滚动到 ListActivity 中的子元素
我有一个 ListActivity 类,它使用 CursorAdapter 填充列表。 我需要做的是根据列表中元素的值让视图向下滚动到列表中的特定元素。
该列表是带有“截止日期”的项目列表,如果截止日期已经过去,我希望视图滚动过去。因此,启动后,用户将在顶部看到最接近截止日期的项目(视图将滚动到该项目)。如果他们想查看过期日期,可以向上滚动。
我希望我能正确解释这一点,我只是想隐藏 ListActivity 中的项目(如果它们的截止日期已经过去),当然是根据活动启动的时间。
I have a ListActivity class that populates a list using a CursorAdapter.
What I need to do is have the view scroll down to a specific element within the list, based on the values of elements in the list.
The list is a list of items with 'due dates' and if the due date has already passed, I want the view to scroll past it. Therefore upon launch, the user will see the item with the nearest due date at the top (the view will be scrolled to this item). If they want to see past due dates, they can scroll up.
I hope I'm explaining this properly, I simply want to hide items in my ListActivity if their due date has already passed, based on the time the Activity is launched of course.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这有效:
This works:
查看项目以找到断点,然后使用
smoothScrollToPosition
函数将动画设置到该位置Android 开发者网站:AbsListView#smoothScrollToPosition
Look through the items to find the break point then use the
smoothScrollToPosition
function to animate to that positionAndroid Developer Site : AbsListView#smoothScrollToPosition
这只是一个想法,但是如果您有一个项目列表,并且可以获取截止日期,并且您还有有关当前日期的信息,为什么不调整列表的重力,使其在顶部显示当前注释....
或者,
如果您在列表视图中有一个注释列表,则在活动的 onresume 和 oncreate 方法中,重新排列列表中的注释,以便将传递的注释放在列表的底部,这样当前音符将始终位于顶部,您不必担心试图干扰重力
this is just an idea, but if you have a list of items and you can grab the due date and you also have information on the current date, why dont you adjust the gravity of the list so that it has the current note at the top....
OR
if you have a list of notes in the listview, in your onresume and oncreate methods for the activity, reshuffle the notes in the list so that the ones that are passed get put to the bottom of the list, that way the current notes will always be on top and you dont have to worry about trying to mess with the gravity