Best code examples for GridView setNumColumns method (android.widget.GridView.setNumColumns)

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

GridView setNumColumns examples from Open Source projects
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, 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: 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: 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
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, 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: 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
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, 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: 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: removeAllViewsInLayout, setAdapter, setNumColumns
51:	mGridView.removeAllViewsInLayout(); 
-
69:	mGridView.setNumColumns(size); 
-
74:	mGridView.setAdapter(adapter); 
Full Snippet Info
5
CodeRank
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
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
This code example shows how to use the following methods: setAdapter, setHorizontalSpacing, setNumColumns, setVerticalSpacing, setOnItemClickListener
154:	mGridView = new GridView(this); 
-
156:	mGridView.setAdapter(localMainMenuAdapter); 
157:	mGridView.setNumColumns(COLUMN_SUM); // 设置3列。 
158:	mGridView.setHorizontalSpacing(1);// 横向间隔 
159:	mGridView.setVerticalSpacing(24);// 纵向间隔 
160:	mGridView.setPadding(6, 4, 6, 0);// 设置填充 
161:	mGridView.setOnItemClickListener(this); 
-
163:	this.mScrollLayout.addView(mGridView, mLayoutParams_wrap); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setNumColumns, setStretchMode
22:	GridView gridView = new GridView(context); 
23:	gridView.setNumColumns(4); 
24:	gridView.setStretchMode(GridView.STRETCH_COLUMN_WIDTH); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setAdapter, setHorizontalSpacing, setNumColumns, setVerticalSpacing, setOnItemClickListener
154:	mGridView = new GridView(this); 
-
156:	mGridView.setAdapter(localMainMenuAdapter); 
157:	mGridView.setNumColumns(COLUMN_SUM); // 设置3列。 
158:	mGridView.setHorizontalSpacing(1);// 横向间隔 
159:	mGridView.setVerticalSpacing(24);// 纵向间隔 
160:	mGridView.setPadding(6, 4, 6, 0);// 设置填充 
161:	mGridView.setOnItemClickListener(this); 
-
163:	this.mScrollLayout.addView(mGridView, mLayoutParams_wrap); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setHorizontalSpacing, setNumColumns, setVerticalSpacing
49:	gvMain.setNumColumns(2); 
-
51:	gvMain.setVerticalSpacing(5); 
52:	gvMain.setHorizontalSpacing(5); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setAdapter, setNumColumns
35:	grid.setAdapter(new ArrayAdapter<String>(this, // 
-
41:	grid.setNumColumns(3); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: setGravity, setHorizontalSpacing, setNumColumns, setStretchMode, setVerticalSpacing
34:	gridView = new GridView(context); 
35:	gridView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, 
-
37:	gridView.setSelector(new ColorDrawable(Color.TRANSPARENT));// 选中的时候为透明色 
38:	gridView.setNumColumns(bodyAdapter.resID.length); 
39:	gridView.setStretchMode(GridView.STRETCH_COLUMN_WIDTH); 
40:	gridView.setVerticalSpacing(0); 
41:	gridView.setHorizontalSpacing(0); 
42:	gridView.setPadding(0, 0, 0, 0); 
43:	gridView.setGravity(Gravity.CENTER); 
44:	gridView.setOnItemClickListener(bodyClick); 
Full Snippet Info
4
CodeRank
This code example shows how to use the following methods: setColumnWidth, setNumColumns
80:	gridView.setNumColumns(1); 
81:	gridView.setColumnWidth(RelativeLayout.LayoutParams.FILL_PARENT); 
Full Snippet Info
4
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: setColumnWidth, setGravity, setHorizontalSpacing, setNumColumns, setVerticalSpacing
80:	ph.adapter.resetDataForReuse(ph.gridView, provider, pageIndex); 
-
143:	GridView g = new GridView(context); 
-
146:	g.setLayoutParams(lp); 
-
152:	g.setColumnWidth(getColumnWidth()); 
153:	g.setNumColumns(mColumns); 
154:	g.setGravity(Gravity.CENTER); 
155:	g.setVerticalSpacing(mVerticleSpace); 
156:	g.setHorizontalSpacing(mHorizontalSpace); 
-
169:	g.setPadding(left, top, right, bottom); 
-
172:	g.setSelector(android.R.color.transparent); 
Full Snippet Info
4
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, 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: setGravity, setHorizontalSpacing, setNumColumns, setStretchMode, setVerticalSpacing
27:	gridView = new GridView(context); 
28:	gridView.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, 
-
30:	gridView.setSelector(new ColorDrawable(Color.TRANSPARENT));// 选中的时候为透明色 
31:	gridView.setNumColumns(4); 
32:	gridView.setStretchMode(GridView.STRETCH_COLUMN_WIDTH); 
33:	gridView.setVerticalSpacing(0); 
34:	gridView.setHorizontalSpacing(0); 
35:	gridView.setPadding(0, 0, 0, 0); 
36:	gridView.setGravity(Gravity.CENTER); 
37:	gridView.setOnItemClickListener(bodyClick); 
Full Snippet Info
4
CodeRank
This code example shows how to use the following methods: setAdapter, setGravity, setHorizontalSpacing, setNumColumns, setStretchMode
31:	gvTitle = new GridView(context); 
32:	gvTitle.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, 
-
34:	gvTitle.setNumColumns(titleAdapter.getCount()); 
35:	gvTitle.setStretchMode(GridView.STRETCH_COLUMN_WIDTH); 
36:	gvTitle.setVerticalSpacing(1); 
37:	gvTitle.setHorizontalSpacing(1); 
38:	gvTitle.setGravity(Gravity.CENTER); 
39:	gvTitle.setOnItemClickListener(titleClick); 
40:	gvTitle.setAdapter(titleAdapter); 
41:	gvTitle.setSelector(new ColorDrawable(Color.TRANSPARENT));// Ñ¡ÖеÄʱºòΪ͸Ã÷É« 
Full Snippet Info
4
CodeRank
This code example shows how to use the following methods: setColumnWidth, setHorizontalSpacing, setNumColumns, setStretchMode, setVerticalSpacing
124:	GridView lv = new GridView(getActivity()); 
125:	lv.setId(android.R.id.list); 
126:	lv.setDrawSelectorOnTop(false); 
127:	lv.setColumnWidth(convertDpToPixels(60, getActivity())); 
128:	lv.setStretchMode(GridView.STRETCH_COLUMN_WIDTH); 
129:	lv.setNumColumns(GridView.AUTO_FIT); 
130:	lv.setHorizontalSpacing(convertDpToPixels(20, getActivity())); 
131:	lv.setVerticalSpacing(convertDpToPixels(20, getActivity())); 
132:	lv.setSmoothScrollbarEnabled(true); 
-
136:	lv.setOverScrollMode(ListView.OVER_SCROLL_NEVER); 
Full Snippet Info
4
CodeRank
This code example shows how to use the following methods: setAdapter, setGravity, setHorizontalSpacing, setNumColumns, setStretchMode
30:	title = new GridView(context); 
31:	title.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); 
32:	title.setNumColumns(titleAdapter.getCount()); 
33:	title.setStretchMode(GridView.STRETCH_COLUMN_WIDTH); 
34:	title.setVerticalSpacing(1); 
35:	title.setHorizontalSpacing(1); 
36:	title.setGravity(Gravity.CENTER); 
37:	title.setOnItemClickListener(titleClick); 
38:	title.setAdapter(titleAdapter); 
39:	title.setSelector(new ColorDrawable(Color.TRANSPARENT));//选中的时候为透明色 
Full Snippet Info
4
CodeRank
Related GridView setNumColumns Questions & Answers:
Other GridView setNumColumns Examples
50:			columnWidth = (int) ((utils.getScreenWidth() - ((AppConstant.NUM_OF_COLUMNS + 1) * padding)) / AppConstant.NUM_OF_COLUMNS);
51:	
52:			gridView.setNumColumns(AppConstant.NUM_OF_COLUMNS);
53:			gridView.setColumnWidth(columnWidth);
54:			gridView.setStretchMode(GridView.NO_STRETCH);

Read More

A view that shows items in two-dimensional scrolling grid. The items in the grid come from the ListAd...
setNumColumns Method Overview
Set the number of columns in the grid
See Also
  • 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.