微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

android – Spinner和ListView有什么区别?

两者都有数据源(或适配器).在我看来,Spinner可以以下拉形式显示,而ListView可以直接显示视图上的所有数据.两者的数据都来自ArrayList.它们可以是String类型,如下所示:

他们有什么不同?

最佳答案
SpinnerList View文档:

Spinners provide a quick way to select one value from a set. In the default state,
a spinner shows its currently selected value. Touching the spinner displays
a dropdown menu with all other available values,from which the user can select
a new one.

ListView is a view group that displays a list of scrollable items. The list items
are automatically inserted to the list using an Adapter that pulls content from a
source such as an array or database query and converts each item result into a view
that’s placed into the list.

尽管它们是从相同的底层数据类型实现的,但是它们之间的区别在于您之前提到的 – 它们的外观和描绘方式.如果你想在你的应用程序中只想从一个集合中选择一个值,那么使用一个微调器就是它们的设计目的.如果您只想显示数据列表,请使用列表视图.在这种情况下,您不会使用微调器,因为旋转器意味着您必须选择一个,而实际上您不想选择任何东西.

原文地址:https://www.jb51.cc/android/430978.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐