Android中如何使GridView的每行自动适应Adapter的个数
1.GridView布局显示
<
GridView
android:id
=
"@+id/service_all_per"
android:layout_width
=
"fill_parent"
android:layout_height
=
"wrap_content"
android:background
=
"@color/white"
android:listSelector
=
"@color/lv_item_bac"
android:fadingEdge
=
"none"
android:stretchMode
=
"columnWidth"
android:numColumns
=
"auto_fit"
>
</
GridView
>
2.gridview设置适配器时添加如下一行代码轻松搞定:
//kongBedBean.bedList.size(); adapter的个数
service_all_per
.setNumColumns(
kongBedBean
.
bedList
.size());