public class

GridView

extends AbsListView
java.lang.Object
   ↳ com.neomades.ui.View
     ↳ com.neomades.ui.AbsListView
       ↳ com.neomades.ui.GridView

Class Overview

A GridView is a grid of views, where only one view could clicked at the same time.

Each view could be different.

Asynchronous data loading with Adapter

First, this grid could load views with adapter instead of calling addView(). Do not call addView() and provide an adapter to be called by this grid when the element becomes visible.

The Adapter has two methods : getCount() and getView() that help grids and lists to load items.

getCount() is called when data is ready to be loaded. This grid will know how many items should be displayed. After that, getView(int, View, View) will be called when a item becomes visible.

When data has changed, be sure calling the notifyDataChanged() method to let the grid or list refreshing views.

Summary

XML Attributes
Attribute Name Related Method Description
listIndicatorVisible setListIndicatorVisible(boolean)  
[Expand]
Inherited XML Attributes
From class com.neomades.ui.AbsListView
From class com.neomades.ui.View
Constants
int STYLE_GROUPED A ListView whose sections present distinct groups of rows.
int STYLE_PLAIN A plain ListView.
[Expand]
Inherited Constants
From interface com.neomades.ui.Alignment
From interface com.neomades.ui.StretchMode
Public Constructors
GridView()
Creates a new grid view.
GridView(int style)
Sets the iOS UITableView style.
Public Methods
void scrollToTop()
Move the scroll position to the first item of the GridView.
void setColumnAlignment(int columnIndex, int alignment)
Sets the column alignment with Alignment constants for the column specified in the parameter.
void setColumnWidth(int width)
Sets the column width in DP unit for every column.
void setHorizontalSpacing(int space)
Set the amount of horizontal (x) spacing to place between each item in the grid.
void setListIndicatorVisible(boolean indicatorVisible)
Displays or hide the list indicator (generally something that represents an arrow at the tight of the ListView cell).
void setNumColumns(int numColumns)
Sets the number of columns of this GridView.
void setRowHeight(int height)
Sets the row height in DP unit for every row.
void setRowHeightAdapter(RowHeightAdapter rowHeightAdapter)
Sets an adapter for row heights.
void setSectionsVisible(boolean visible)
Enables or not section items in the list.
void setVerticalSpacing(int space)
Set the amount of vertical (y) spacing to place between each item in the grid.
[Expand]
Inherited Methods
From class com.neomades.ui.AbsListView
From class com.neomades.ui.View
From class java.lang.Object

XML Attributes

listIndicatorVisible

Constants

public static final int STYLE_GROUPED

A ListView whose sections present distinct groups of rows. The section headers and footers do not float.

Constant Value: 1 (0x00000001)

public static final int STYLE_PLAIN

A plain ListView. Any section headers or footers are displayed as inline separators and float when the ListView is scrolled.

Constant Value: 0 (0x00000000)

Public Constructors

public GridView ()

Creates a new grid view.

public GridView (int style)

Sets the iOS UITableView style. (Only for iOS)

Parameters
style STYLE_PLAIN (default) or STYLE_GROUPED

Public Methods

public void scrollToTop ()

Move the scroll position to the first item of the GridView.

public void setColumnAlignment (int columnIndex, int alignment)

Sets the column alignment with Alignment constants for the column specified in the parameter.

A column alignment could be set if the view given by the adapter is in MATCH_CONTENT mode or has a fixed width.

By default, the left alignment is set.

Parameters
columnIndex 0 for the first column, a positive value for other columns, should be less than the number of columns
alignment LEFT, HCENTER , RIGHT

public void setColumnWidth (int width)

Sets the column width in DP unit for every column.

Use this method to apply the same width to all columns.

Parameters
width the column width in DP

public void setHorizontalSpacing (int space)

Set the amount of horizontal (x) spacing to place between each item in the grid.

Parameters
space The amount of horizontal space between items, in DP unit.

public void setListIndicatorVisible (boolean indicatorVisible)

Displays or hide the list indicator (generally something that represents an arrow at the tight of the ListView cell).

Related XML Attributes
Parameters
indicatorVisible true to display the indicator

public void setNumColumns (int numColumns)

Sets the number of columns of this GridView.

Parameters
numColumns number of columns
Throws
CrossThreadException if the method is called from outside the UI-Thread

public void setRowHeight (int height)

Sets the row height in DP unit for every row.

Use this method if this is the same row height for each row.

This method could not be used if a RowHeightAdapter is set. See setRowHeightAdapter(RowHeightAdapter)

Parameters
height the row height in DP

public void setRowHeightAdapter (RowHeightAdapter rowHeightAdapter)

Sets an adapter for row heights.

The adapter gives an height for each row (could be different).

Parameters
rowHeightAdapter an adapter or null

public void setSectionsVisible (boolean visible)

Enables or not section items in the list.

Cross Platform considerations

This method does nothing on Android.

Parameters
visible true to show sections

public void setVerticalSpacing (int space)

Set the amount of vertical (y) spacing to place between each item in the grid.

Parameters
space The amount of vertical space between items, in DP unit.