为什么android里有ListVIew?

Why there is ListVIew in android?

我的问题是 android 中有 ListViewGridview

List view as

<ListView
  android:id="@android:id/list"
  android:layout_width="match_parent"
  android:layout_height="wrap_content" >
</ListView>

现在假设我为 ListView 设置了所有内容,即适配器,为列表创建了数据。 现在代替 ListView 只需将 GridView 替换为

<GridView xmlns:android="http://schemas.android.com/apk/res/android" 
   android:id="@+id/gridview"
   android:layout_width="fill_parent" 
   android:layout_height="fill_parent"
   android:numColumns="1"/>

GridView act like ListView then why there is ListView ,if we can achive all the functionality of ListView by GridView assinging android:numCloumns="1"? Any specific use of list?

我知道GridView用于排列项目的行列。

查看 Android 开发人员 docs,ListView 和 Gridiew 的父 class 相同,即 android.widget.AbsListView
现在这个 class 可用于实现项目的虚拟化列表。并且这个 class 的子类可以将列表的内容显示在网格、轮播、堆栈等中

所以从开发的角度来看,正如您已经指出的那样,您可以通过其中任何一个来实现相同的效果。

Perhaps, answer to this lies in Design of Application and has more to do with User experience in certain use cases.

列表样式布局适用于那些行动目的往往非常单一的用户。他们来到您的应用程序是为了做一件事:浏览或阅读。以标准方式向他们展示内容,让他们沉浸其中。
另一方面,网格视图用于快速访问内容。它适合不安分和好奇的人。您的注意力从一个主题或图像转移到下一个主题或图像,您永远不想在一个地方逗留太久。当您厌倦了站立时,只需单击您感兴趣的主题以了解更多详细信息,然后坐下来慢慢享受并完全沉浸其中。

简而言之,列表视图为用户提供了一种遵循用户自然阅读模式的格式,而网格视图则更具干扰性,使其最适合视觉内容。您可以从一个图像跳到下一个图像,而不必担心顺序或连续性。这一切都是关于发现和看到一切。

检查您的应用程序数据中哪些内容更重要。对于基于 image 的内容,最好的选择是网格视图。对于基于数据的内容,更好的选择是列表视图。

此外,网格视图还提供了一项附加功能:网格列表可以垂直或水平滚动。

因此,除了用户体验之外,如果需要,网格视图还提供了更大的灵活性!