【问题标题】:grid view i have to display the 3X3 matrix how to do that网格视图我必须显示 3X3 矩阵怎么做
【发布时间】:2013-06-04 06:25:42
【问题描述】:

网格视图我必须显示 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

【问题讨论】:

    标签: java android gridview


    【解决方案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)
    

    【讨论】:

      【解决方案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"
              >
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-01-27
        • 1970-01-01
        • 2017-07-29
        • 2016-10-29
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多