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