Best code examples for Android GridView class (android.widget.GridView)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android GridView class.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

Android GridView examples from Open Source projects
Examples using Android GridView getAdapter method:
This code example shows how to use the following methods: getAdapter, getNumColumns, getLayoutParams, setLayoutParams
277:	int itemCount = gv.getAdapter().getCount(); 
278:	int columns = gv.getNumColumns(); 
-
283:	ViewGroup.LayoutParams lp = gv.getLayoutParams(); 
-
285:	gv.setLayoutParams(lp); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: getAdapter, getNumColumns, getLayoutParams, setLayoutParams
281:	int itemCount = gv.getAdapter().getCount(); 
282:	int columns = gv.getNumColumns(); 
-
287:	ViewGroup.LayoutParams lp = gv.getLayoutParams(); 
-
289:	gv.setLayoutParams(lp); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getChildAt, getChildCount, getAdapter, getListPaddingTop
75:	View firstChild = mGridView.getChildAt(0); 
76:	if (firstChild.getTop() < this.mGridView.getListPaddingTop()) { 
77:	firstChild = mGridView.getChildAt(1); 
-
80:	View lastChild = mGridView.getChildAt(mGridView.getChildCount() - 1); 
-
87:	View newLastChild = mGridView.getChildAt(mGridView.getChildCount() - 1); 
-
90:	assertEquals("Wrong view in last position", mGridView.getAdapter().getCount() - 1, 
Full Snippet Info
6
CodeRank
Examples using Android GridView setAdapter method:
This code example shows how to use the following methods: setAdapter, setVisibility
101:	mGridView.setAdapter(mAdapter); 
-
105:	mGridView.setVisibility(VISIBLE); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setAdapter, setOnItemClickListener, setOnScrollListener
302:	mShelfView.setAdapter(mShelfAdapter); 
303:	mShelfView.setOnScrollListener(mShelfAdapter); 
-
306:	mShelfView.setOnItemClickListener(mOnShelfItemClickListener); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setAdapter
71:	emotionGrid.setAdapter(adapter); 
Full Snippet Info
6
CodeRank
Examples using Android GridView setColumnWidth method:
This code example shows how to use the following methods: setAdapter, setColumnWidth, setHorizontalSpacing, setNumColumns, getLayoutParams
53:	LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams)m_oInfoGrid.getLayoutParams(); 
-
55:	m_oInfoGrid.setLayoutParams(lp); 
-
57:	m_oInfoGrid.setNumColumns(4); 
58:	m_oInfoGrid.setColumnWidth(dm.widthPixels/4); 
59:	m_oInfoGrid.setHorizontalSpacing(10); 
-
66:	m_oInfoGrid.setAdapter(sa); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setAdapter, setColumnWidth, setHorizontalSpacing, setStretchMode, setVerticalSpacing
21:	gridView.setHorizontalSpacing(0); 
-
25:	gridView.setColumnWidth(screenWidth / 3 - margin * 2 / 3); 
26:	gridView.setStretchMode(GridView.NO_STRETCH); 
27:	gridView.setHorizontalSpacing(margin / 2); 
28:	gridView.setVerticalSpacing(margin / 2); 
-
30:	gridView.setAdapter(adapter); 
31:	gridView.setRecyclerListener(adapter); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setColumnWidth, setHorizontalSpacing, setNumColumns, setVerticalSpacing, getLayoutParams
125:	RelativeLayout.LayoutParams param = (RelativeLayout.LayoutParams)view.getLayoutParams(); 
-
130:	view.setNumColumns(numColumns); 
131:	view.setColumnWidth(mIconSize); 
132:	view.setHorizontalSpacing(mIconSpacing); 
133:	view.setVerticalSpacing(mIconSpacing); 
134:	view.setLayoutParams(param); 
Full Snippet Info
5
CodeRank
Examples using Android GridView setNumColumns method:
This code example shows how to use the following methods: setAdapter, setNumColumns
41:	grid = new GridView(context); 
-
51:	grid.setNumColumns(columnCount); 
52:	grid.setAdapter(adapter); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setAdapter, setHorizontalSpacing, setNumColumns, setVerticalSpacing, setOnItemClickListener
155:	mGridView = new GridView(this); 
-
157:	mGridView.setAdapter(localMainMenuAdapter); 
158:	mGridView.setNumColumns(COLUMN_SUM); // 设置3列。 
159:	mGridView.setHorizontalSpacing(1);// 横向间隔 
160:	mGridView.setVerticalSpacing(24);// 纵向间隔 
161:	mGridView.setPadding(6, 4, 6, 0);// 设置填充 
162:	mGridView.setOnItemClickListener(this); 
-
164:	this.mScrollLayout.addView(mGridView, mLayoutParams_wrap); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setAdapter, setNumColumns
68:	GridView gridView = new GridView( context ); 
-
70:	gridView.setNumColumns( 4 ); 
71:	IngredientGridViewAdapter adapter = new IngredientGridViewAdapter( handler, relativeLayout, gridView, context, layoutInflater, infos ); 
72:	gridView.setAdapter( adapter ); 
Full Snippet Info
6
CodeRank
Examples using Android GridView getNumColumns method:
This code example shows how to use the following methods: getAdapter, getNumColumns, getLayoutParams, setLayoutParams
281:	int itemCount = gv.getAdapter().getCount(); 
282:	int columns = gv.getNumColumns(); 
-
287:	ViewGroup.LayoutParams lp = gv.getLayoutParams(); 
-
289:	gv.setLayoutParams(lp); 
Full Snippet Info
6
CodeRank
Examples using Android GridView setGravity method:
This code example shows how to use the following methods: setColumnWidth, setGravity, setNumColumns, setVerticalSpacing, setOverScrollMode
19:	gv.setColumnWidth(200); 
20:	gv.setGravity(Gravity.CENTER); 
21:	gv.setOverScrollMode(View.OVER_SCROLL_ALWAYS); 
22:	gv.setNumColumns(GridView.AUTO_FIT); 
23:	gv.setVerticalSpacing(15); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setGravity, setHorizontalSpacing, setNumColumns, setStretchMode, setVerticalSpacing
74:	mGridView = new GridView(mContext); 
75:	mGridView.setNumColumns(4); 
76:	mGridView.setHorizontalSpacing(10); 
77:	mGridView.setVerticalSpacing(10); 
78:	mGridView.setStretchMode(GridView.STRETCH_COLUMN_WIDTH); 
79:	mGridView.setGravity(Gravity.CENTER); 
80:	mGridView.setOnItemClickListener(this); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setAdapter, setGravity, setNumColumns, setStretchMode, setPadding
157:	gridView = new GridView(mContext); 
-
159:	gridView.setVerticalScrollBarEnabled(false); 
-
161:	gridView.setNumColumns(currentRow.size()); 
162:	gridView.setPadding(1,1,1,1); 
-
164:	gridView.setGravity(Gravity.CENTER); 
165:	gridView.setStretchMode(GridView.STRETCH_COLUMN_WIDTH); 
-
173:	gridView.setAdapter(itemAdapter); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setAdapter, setColumnWidth, setHorizontalSpacing, setNumColumns, setStretchMode
40:	GridView gridview = new GridView(this); 
41:	gridview.setNumColumns(GridView.AUTO_FIT); 
42:	gridview.setHorizontalSpacing(40); 
43:	gridview.setVerticalSpacing(40); 
44:	gridview.setPadding(20, 20, 20, 0); 
45:	gridview.setFastScrollEnabled(true); 
46:	gridview.setColumnWidth(iconSize); 
47:	gridview.setStretchMode(GridView.STRETCH_COLUMN_WIDTH); 
-
49:	gridview.setAdapter(new ImageAdapter(this, pkgName)); 
50:	gridview.setOnItemClickListener(new AdapterView.OnItemClickListener() { 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setAdapter, setHorizontalSpacing, setNumColumns, setVerticalSpacing, setOnItemClickListener
132:	mGridView = new GridView(this); 
-
134:	mGridView.setAdapter(localMainMenuAdapter); 
135:	mGridView.setNumColumns(COLUMN_SUM); // 设置3列。 
136:	mGridView.setHorizontalSpacing(1);// 横向间隔 
137:	mGridView.setVerticalSpacing(24);// 纵向间隔 
138:	mGridView.setPadding(6, 4, 6, 0);// 设置填充 
139:	mGridView.setOnItemClickListener(this); 
-
141:	this.mScrollLayout.addView(mGridView, mLayoutParams_wrap); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setAdapter, setHorizontalSpacing, setNumColumns, setVerticalSpacing, setOnItemClickListener
152:	mGridView = new GridView(this); 
-
154:	mGridView.setAdapter(localMainMenuAdapter); 
155:	mGridView.setNumColumns(COLUMN_SUM); // 设置3列。 
156:	mGridView.setHorizontalSpacing(1);// 横向间隔 
157:	mGridView.setVerticalSpacing(24);// 纵向间隔 
158:	mGridView.setPadding(6, 4, 6, 0);// 设置填充 
159:	mGridView.setOnItemClickListener(this); 
-
161:	this.mScrollLayout.addView(mGridView, mLayoutParams_wrap); 
Full Snippet Info
5
CodeRank
Examples using Android GridView setSelection method:
This code example shows how to use the following methods: setAdapter, setSelection, invalidate
106:	menuGrid.setAdapter(getMenuAdapter(menu_name_array2, 
-
114:	menuGrid.invalidate();// ����menu 
115:	menuGrid.setSelection(ITEM_MORE); 
Full Snippet Info
5
CodeRank
Examples using Android GridView setVerticalSpacing method:
This code example shows how to use the following methods: setAdapter, setHorizontalSpacing, setNumColumns, setVerticalSpacing, setOnItemClickListener
169:	mGridView = new GridView(this); 
-
171:	mGridView.setAdapter(localMainMenuAdapter); 
172:	mGridView.setNumColumns(COLUMN_SUM); // 设置3列。 
173:	mGridView.setHorizontalSpacing(1);// 横向间隔 
174:	mGridView.setVerticalSpacing(24);// 纵向间隔 
175:	mGridView.setPadding(6, 4, 6, 0);// 设置填充 
176:	mGridView.setOnItemClickListener(this); 
-
178:	this.mScrollLayout.addView(mGridView, mLayoutParams_wrap); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setAdapter, setHorizontalSpacing, setNumColumns, setVerticalSpacing, setOnItemClickListener
169:	mGridView = new GridView(this); 
-
171:	mGridView.setAdapter(localMainMenuAdapter); 
172:	mGridView.setNumColumns(COLUMN_SUM); // 设置3列。 
173:	mGridView.setHorizontalSpacing(1);// 横向间隔 
174:	mGridView.setVerticalSpacing(24);// 纵向间隔 
175:	mGridView.setPadding(6, 4, 6, 0);// 设置填充 
176:	mGridView.setOnItemClickListener(this); 
-
178:	this.mScrollLayout.addView(mGridView, mLayoutParams_wrap); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setAdapter, setHorizontalSpacing, setNumColumns, setVerticalSpacing, setOnItemClickListener
133:	mGridView = new GridView(this); 
-
136:	mGridView.setAdapter(localMainMenuAdapter); 
137:	mGridView.setNumColumns(COLUMN_SUM); // 设置3列。 
138:	mGridView.setHorizontalSpacing(1);// 横向间隔 
139:	mGridView.setVerticalSpacing(24);// 纵向间隔 
140:	mGridView.setPadding(6, 4, 6, 0);// 设置填充 
141:	mGridView.setOnItemClickListener(this); 
-
143:	this.mScrollLayout.addView(mGridView,mLayoutParams_wrap); 
Full Snippet Info
5
CodeRank
Examples using Android GridView setStretchMode method:
This code example shows how to use the following methods: setGravity, setHorizontalSpacing, setNumColumns, setStretchMode, setVerticalSpacing
81:	gvTitle = new GridView(activity); 
82:	gvTitle.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, 
-
84:	gvTitle.setNumColumns(4); 
85:	gvTitle.setStretchMode(GridView.STRETCH_COLUMN_WIDTH); 
86:	gvTitle.setVerticalSpacing(15); 
87:	gvTitle.setHorizontalSpacing(10); 
88:	gvTitle.setPadding(10, 10, 10, 10); 
89:	gvTitle.setGravity(Gravity.CENTER); 
Full Snippet Info
5
CodeRank
Related Android GridView Questions & Answers:
Other Android GridView Examples
15:	
16:			GridView gridView = (GridView) findViewById(R.id.grid_view);
17:	
18:			// Instance of ImageAdapter Class
19:			gridView.setAdapter(new ImageAdapter(this));
-
15:	
16:			GridView gridView = (GridView) findViewById(R.id.grid_view);
17:	
18:			// Instance of ImageAdapter Class
19:			gridView.setAdapter(new ImageAdapter(this));

Read More

15:	
16:			GridView gridView = (GridView) findViewById(R.id.grid_view);
17:	
18:			// Instance of ImageAdapter Class
19:			gridView.setAdapter(new ImageAdapter(this));
-
15:	
16:			GridView gridView = (GridView) findViewById(R.id.grid_view);
17:	
18:			// Instance of ImageAdapter Class
19:			gridView.setAdapter(new ImageAdapter(this));

Read More

17:		private ArrayList<String> imagePaths = new ArrayList<String>();
18:		private GridViewImageAdapter adapter;
19:		private GridView gridView;
20:		private int columnWidth;
21:	
-
25:			setContentView(R.layout.activity_grid_view);
26:	
27:			gridView = (GridView) findViewById(R.id.grid_view);
28:	
29:			utils = new Utils(this);

Read More

3:	    setContentView(R.layout.main);
4:	
5:	    GridView gridview = (GridView) findViewById(R.id.gridview);
6:	    gridview.setAdapter(new ImageAdapter(this));
7:	
-
3:	    setContentView(R.layout.main);
4:	
5:	    GridView gridview = (GridView) findViewById(R.id.gridview);
6:	    gridview.setAdapter(new ImageAdapter(this));
7:

Read More

GridView Class Overview
A view that shows items in two-dimensional scrolling grid. The items in the grid come from the ListAd...
Methods
  • getAdapter
    Returns the adapter currently associated with this widget.
  • setHorizontalSpacing
    Set the amount of horizontal (x) spacing to place between each item in the grid.
  • setVerticalSpacing
    Set the amount of vertical (y) spacing to place between each item in the grid.