简体   繁体   English

android Gridview中的自定义行和列

[英]Custom Row and Column in android Gridview

在此处输入图片说明 How can i develop a grid view with custom row and column ,which means i need to specify the number of row and column of the gridView ; 如何使用自定义行和列开发网格视图,这意味着我需要指定gridView的行数和列数; I have a metrics like data inhand and need to display in the manner they are being for example 我手头有一个类似数据的指标,并且需要以例如它们的方式显示

(0,0) (0,1) (0,0)(0,1)
(1,0) (1,1) (1,0)(1,1)

like this formate i need to display also need to scroll horizontally and vertically as the size of data 像这样的队友,我需要显示也需要水平和垂直滚动作为数据的大小

You can set the number of columns you want in the grid view with android:numColumns="x" . 您可以使用android:numColumns="x"设置网格视图中所需的列数。 To the best of my knowledge there is no way to exactly specify the number of rows for a grid view via xml (or programmatically). 据我所知,无法通过xml(或以编程方式)为网格视图精确指定行数。 You can control the number of rows shown in a grid view by using an Adapter class that is populated with (number of rows you want * number of columns you want) items 您可以使用填充了(number of rows you want * number of columns you want)项的Adapter类来控制网格视图中显示(number of rows you want * number of columns you want)

For example, if you want your grid to be 2x2, set android:numColumns="2" in xml and populate whatever adapter that serves the grid view with 4 items 例如,如果您希望网格为2x2,则在xml中设置android:numColumns="2"并填充提供4个网格视图的适配器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM