7.12. GridView(网格组件)
继承机构如下:
|
||||||||||||||||||||||||||||||||||||

同样的,跟GralleryView组件相似,设置GridView中的内容使用适配器Adapter来完成,可以使用SimpleAdapter和BaseAdapter。
以下通过SimpleAdapter来完成。
配置:
| <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <GridView android:id="@+id/myGridView" android:layout_width="fill_parent" android:layout_height="wrap_content" android:numColumns="3" android:stretchMode="columnWidth"/> </LinearLayout>
|
自定义组件:
| <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android: |

本文详细介绍了Android中的GridView组件,它作为网格布局管理器,允许以网格形式展示数据。讲解了GridView的继承结构,并强调通过Adapter(如SimpleAdapter和BaseAdapter)来设置内容。示例中特别提到了使用SimpleAdapter的方法,并提供了配置和自定义组件的概述,包括点击图片后显示的对话组件实现。
最低0.47元/天 解锁文章
796

被折叠的 条评论
为什么被折叠?



