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
This code example shows how to use the following methods: getLayoutParams, setLayoutParams, getAdapter, getNumColumns
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: setVisibility, setAdapter
101:	mGridView.setAdapter(mAdapter); 
-
105:	mGridView.setVisibility(VISIBLE); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: setOnScrollListener, setAdapter, setOnItemClickListener
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: getTop, getChildAt, getChildCount
88:	View lastChild = mGridView.getChildAt(mGridView.getChildCount() - 1); 
-
93:	mGridView.getTop()); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getLayoutParams, setLayoutParams, getAdapter, getNumColumns
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, getListPaddingTop, getAdapter
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
This code example shows how to use the following methods: getLayoutParams, setLayoutParams, getAdapter
279:	int itemCount = gv.getAdapter().getCount(); 
-
284:	ViewGroup.LayoutParams lp = gv.getLayoutParams(); 
-
286:	gv.setLayoutParams(lp); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getHeight, getChildAt, getChildCount, getListPaddingBottom, getAdapter
88:	TouchUtils.dragViewToTop(this, mGridView.getChildAt(mGridView.getChildCount() - 1), 2); 
-
92:	mGridView.getSelectedItemPosition()); 
-
94:	View lastChild = mGridView.getChildAt(mGridView.getChildCount() - 1); 
-
97:	mGridView.getAdapter().getCount() - 1, lastChild.getId()); 
-
100:	mGridView.getHeight() - mGridView.getListPaddingBottom(), lastChild.getBottom()); 
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
This code example shows how to use the following methods: invalidateViews
58:	mColorsGrid.invalidateViews(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getLayoutParams, setLayoutParams, setAdapter, setColumnWidth, setHorizontalSpacing
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: setVisibility, setAdapter
137:	mGrid.setAdapter(mAdapter); 
-
147:	mGrid.setVisibility(empty ? View.GONE : View.VISIBLE); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setAdapter, getSelectedItemId, setEmptyView, setOnItemClickListener
234:	return mGrid.getSelectedItemId(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: scrollToBottom, getHeight, getChildAt, getChildCount, getListPaddingBottom
72:	TouchUtils.scrollToBottom(this, mGridView); 
-
76:	mGridView.getSelectedItemPosition()); 
-
78:	View lastChild = mGridView.getChildAt(mGridView.getChildCount() - 1); 
-
80:	assertEquals("Grid is not scrolled to the bottom", mGridView.getAdapter().getCount() - 1, 
-
84:	mGridView.getHeight() - mGridView.getListPaddingBottom(), lastChild.getBottom()); 
Full Snippet Info
6
CodeRank
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: setRecyclerListener, setAdapter, setColumnWidth, setHorizontalSpacing, setStretchMode
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: getLayoutParams, setLayoutParams, setColumnWidth, setHorizontalSpacing, setNumColumns
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
This code example shows how to use the following methods: getLayoutParams, setLayoutParams, getAdapter, getNumColumns
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
This code example shows how to use the following methods: setOverScrollMode, setColumnWidth, setGravity, setNumColumns, setVerticalSpacing
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: setOnScrollListener, getAdapter, setAdapter, setOnItemClickListener
106:	if (null == gridView.getAdapter()) { 
107:	gridView.setAdapter(ima); 
-
109:	gridView.setOnScrollListener(new GridScrollListener(ima, icatalog)); 
110:	gridView.setOnItemClickListener(new OnGalleryItemClick(icatalog)); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getTop, getChildAt, getChildCount
88:	View lastChild = mGridView.getChildAt(mGridView.getChildCount() - 1); 
-
93:	mGridView.getTop()); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setPadding, setFastScrollEnabled, setAdapter, setColumnWidth, setHorizontalSpacing
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, getSelectedItemId, setEmptyView, setOnItemClickListener
239:	return mGrid.getSelectedItemId(); 
Full Snippet Info
5
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: setPadding, setAdapter, setHorizontalSpacing, setNumColumns, setVerticalSpacing
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: invalidate, setAdapter, setSelection
106:	menuGrid.setAdapter(getMenuAdapter(menu_name_array2, 
-
114:	menuGrid.invalidate();// ����menu 
115:	menuGrid.setSelection(ITEM_MORE); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setPadding, setVerticalScrollBarEnabled, setAdapter, setGravity, setNumColumns
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: setPadding, setAdapter, setHorizontalSpacing, setNumColumns, setVerticalSpacing
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
This code example shows how to use the following methods: setPadding, setAdapter, setHorizontalSpacing, setNumColumns, setVerticalSpacing
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
This code example shows how to use the following methods: getAdapter, setAdapter, setNumColumns
116:	grid.setNumColumns(activeQuestion.getColumns()); 
117:	grid.setAdapter(new AnswersAdapter(activeQuestion, this)); 
-
126:	((AnswersAdapter) grid.getAdapter()).setResult(result); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: getCheckedItemCount
152:	int selectCount = mGrid.getCheckedItemCount(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setPadding, setAdapter, setHorizontalSpacing, setNumColumns, setVerticalSpacing
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: setPadding, setAdapter, setHorizontalSpacing, setNumColumns, setVerticalSpacing
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: setPadding, setAdapter, setHorizontalSpacing, setNumColumns, setVerticalSpacing
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
This code example shows how to use the following methods: setLayoutParams, setPadding, setGravity, setHorizontalSpacing, setNumColumns
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
This code example shows how to use the following methods: setId, setLayoutParams, setAdapter, setHorizontalSpacing, setVerticalSpacing
297:	title_gView.setLayoutParams(params); 
298:	title_gView.setVerticalSpacing(0);// 垂直间隔 
299:	title_gView.setHorizontalSpacing(0);// 水平间隔 
-
301:	title_gView.setAdapter(titleAdapter);// 设置菜单Adapter 
302:	title_gView.setId(caltitleLayoutID); 
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

See Code Examples for Android GridView Methods: