Android programming simple implementation of Jiugong grid example

This paper describes the simple implementation of Jiugong grid in Android programming. Share with you for your reference, as follows:

Implementation steps

1. An integral container part. The above figure includes all parts of the whole picture item. Here we use GridView (table layout) to implement it

2. In the whole interface, you should pay attention to the "repeated part", which is the text displayed under each picture item and picture. Then we need to describe this part. When describing, explain that the picture is at the top and the text is at the bottom.

3. Insert (put) each item into the container iteratively or repeatedly. Three files need to be added / modified: main.xml, meintem.xml and activity

The source code of main.xml is as follows. It is a girdview for loading items:

The property that needs attention here is columnwidth, which specifies the column width. A column object corresponds to a "repeatable sub item", which is our picture item and the text display below the picture. If this width is not specified, only one "repeatable sub item" is displayed in each line (displayed line, interface) by default. When the width is specified, it is specified as 90dp in this paper. If the actual line size of each line is greater than 90, it will continue to place the next "repeatable sub item" on the line. Thus, a situation is presented in which multiple children are displayed in a row. The numcolumns property specifies an autofill value indicating the autofill row.

2。 Specifying repeatable children is the part that needs to be displayed iteratively

Android: numcolumns = "auto_fit", the number of columns in GridView is set to automatic Android: columnwidth = "90dp", the width of each column, that is, the width of item Android: stretchmode = "columnwidth", the scaling is synchronized with the size of column width, Android: verticalspating = "10dp", the margin between two rows, such as the spacing between row 1 (No.0 ~ No.2) and row 2 (No.3 ~ No.5) is 10dp, Android: horizontalspacing = "10dp", The margin between two columns.

Next, we will introduce meintem.xml, which is similar to imageitem.xml of listview:

Finally, the Java source code

More readers interested in Android related content can view the special topics of this site: introduction and advanced tutorial of Android development, summary of Android debugging skills and common problem solving methods, summary of Android basic component usage, summary of Android view skills, summary of Android layout skills and summary of Android control usage

I hope this article will help you in Android programming.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>