android 搜索列表视图?
我创建了列表视图如下...
lv = (ListView) findViewById(R.id.listview);
lv.setAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_checked, mDisplay));
我的问题是我需要使列表视图可搜索,这样如果用户输入字母表,列表视图必须滚动到以该字母表开头的该项目(我不希望它被过滤)列表项可见...
例如,如果用户按“f”,我希望列表滚动到带有“f”的第一项,如下所示
我不希望其如下所示:
抱歉如果问题无法理解,因为我不知道如何表达,
请询问我是否需要更多详细信息...
谢谢:)
i have created listview as follows...
lv = (ListView) findViewById(R.id.listview);
lv.setAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_checked, mDisplay));
my question is that i need to make the listview searchable such that if the user enters an alphabet the listview must scroll to that item starting with that alphabet (i dont want it to be filtered) with all the list items visible ...
for example if the user press "f" i want the list to scroll to the 1st item with "f" as follows
i DONT want it to be as follows:
i am sorry if the question is not understandable because i dont know how to put it
ask me if u need more details...
thanks :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
以下链接可能会帮助您键入时的 Android 搜索列表
following link might help you Android search list while typing
我不知道是否有适合您要求的东西。但你可以通过这样的逻辑来实现它。
每当用户按下 f 时,请检查数组列表中 f 中的单词从哪个位置开始。说从第 5 个位置开始。
并使用
listview.smoothScrollToPosition(intposition)
I don't know if something for your requirement in readly available. But you can implement it through a logic like this.
Whenever user presses say f, check in your arraylist from which position words from f starts. say from 5th position it starts.
and use
listview.smoothScrollToPosition(int position)