2013-06-04 9 views
2

網格視圖我必須顯示3X3矩陣如何做到這一點。網格視圖我必須顯示3X3矩陣如何做到這一點

輸入值是水平值和垂直值。

例如水平值是3和垂直值3,那麼我必須diaplay以下格式

1 2 3 
4 5 6 
7 8 9 

例如水平值是2和垂直值2,那麼我必須diaplay以下格式

1 2 
3 4 

例如水平值是3和垂直值2,那麼我必須diaplay以下格式

1 2 3 
4 5 6 

回答

0

試試這個...

 <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" 
     > 
1

根據您的情況使用以下方法:

  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) 
相關問題