gpt4 book ai didi

android - Spinner 和 ListView 有什么区别?

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:46:17 24 4
gpt4 key购买 nike

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

<string-array name="Cities">
<item >Beijing</item>
<item >Tokoy</item>
<item >New York</item>
<item >London</item>
<item >Paris</item>
<item >Berlin</item>
<item >Moscow</item>
<item >Hongkong</item>
</string-array>

它们有什么区别?

最佳答案

来自 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.

尽管它们是从相同的基础数据类型实现的,但它们的不同之处在于您之前提到的 - 它们看起来和描述数据的方式。如果您希望在您的应用程序中仅从集合中选择一个 值,那么请使用微调器,因为它们就是为此而设计的。如果您只想显示数据列表,请使用 ListView 。在这种情况下,您不会使用微调器,因为微调器意味着您必须选择一个,而实际上您不想选择任何东西。

关于android - Spinner 和 ListView 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20728920/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com