为什么Android中有ListVIew?(Why there is ListVIew in android?)

编程入门 行业动态 更新时间:2024-10-24 20:23:14
为什么Android中有ListVIew?(Why there is ListVIew in android?)

我的问题是我们在android中有ListView和Gridview 。

列表视图为

<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就像ListView那样为什么有ListView ,如果我们能够通过GridView实现ListView的所有功能来配合android:numCloumns="1" ? 列表的具体用途是什么?

我知道GridView用于在行和列中排列项目。

My question is that we have ListView and Gridview in android.

List view as

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

Now suppose I setup everything for ListView i.e adapter , created data for list. Now instead of ListView just replace the GridView as

<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?

I know GridView is used to arrange the item in row and column.

最满意答案

查看Android开发人员文档 ,ListView和Gridiew的父类是相同的,即android.widget.AbsListView 。 现在这个类可以用来实现项目的虚拟化列表。 此类的子类可以在网格中,在轮播中,作为堆栈等显示列表的内容。

因此,正如您已经指出的那样,从开发人员的角度来看,您可以通过其中任何一个获得相同的效果。

或许,答案就在于应用程序设计,并且在某些用例中更多地与用户体验有关。

列表样式布局适用于那些其行为往往非常单一的用户。 他们来你的应用程序做一件事:浏览或阅读。 以标准方式向他们展示内容,让他们迷失在其中。 另一方面,网格视图用于快速访问内容。 这是为了不安和好奇。 你的注意力从一个主题或图像到下一个,你永远不想在一个地方逗留太久。 当您厌倦了站立时,您只需点击您感兴趣的主题以获取更多详细信息并拥有座位,这样您就可以花时间并完全被吸引住。

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

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

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

因此除了用户体验之外,网格视图还可根据需要提供更多灵活性

Looking at the Android developer docs, the parent class for both ListView and Gridiew is same and that is android.widget.AbsListView. Now this class that can be used to implement virtualized lists of items. And subclases of this class can display the content of the list in a grid, in a carousel, as stack, etc.

So from Development's view, as you already pointed out, you may be able to achieve same effect by either of them.

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

A list style layout is for those users whose actions tend to be very singular in purpose. They've come to your Application to do one thing: browse or read. Present them with content in a standard way and let them just get lost in it. On the other hand, grid view is for the quick access of content. It's for the restless and curious. Your attention goes from one topic or image to the next and you never want to linger in one spot for too long. And when you get tired of standing, you just click into your topic of interest for more details and have a seat so you can take your time and become completely enthralled.

In a Nutshell, List view provides users a format that follows user's natural reading patterns, while grid view is a little more interruptive, making it best suited for visual content. You can jump from one image to the next without worrying about order or continuity. It's all about discovery and just seeing everything.

Check what is more important in YOUR Application's data. For image based content the best option is the grid view. For data based content a better option is the list view.

Also, Grid View offers an additional functionality: grid lists may scroll either vertically or horizontally.

So apart from User Experience Grid view also offers more flexibility if required!

更多推荐

本文发布于:2023-08-07 00:48:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1458974.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:中有   Android   android   ListVIew

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!