网格视图我必须显示 3X3 矩阵如何做到这一点。
输入值是水平值和垂直值。
例如水平值为 3,垂直值为 3,然后我必须显示为以下格式
1 2 3
4 5 6
7 8 9
例如水平值为 2 垂直值为 2 然后我必须显示为以下格式
1 2
3 4
例如水平值为 3,垂直值为 2,那么我必须显示为以下格式
1 2 3
4 5 6
根据您的情况使用以下方法:
setNumColumns(int)
这将在运行时设置列数。
for example horizontal value is 3 and vertical value 3 then i have to diaplay to below format
setNumColumns(3)
for example horizontal value is 2 and vertical value 2 then i have to diaplay to below format
setNumColumns(2)
for example horizontal value is 3 and vertical value 2 then i have to diaplay to below format
setNumColumns(2)
试试这个...
<GridView
android:id="@+id/myGrid"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layoutAnimation="@anim/layout_grid_fade"
android:columnWidth="90dp"
android:numColumns="3"
android:verticalSpacing="10dp"
android:horizontalSpacing="10dp"
android:scrollbarStyle="outsideOverlay"
android:gravity="center"
android:scrollbars="vertical"
android:stretchMode="columnWidth"
>