GridView setNumColumns - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for GridView setNumColumns method.

This code example shows how to use the following methods:getLayoutParams, setLayoutParams, setAdapter, setColumnWidth, setHorizontalSpacing
	    	m_oTitle2Text.setText("����������20��");
	    } 
	     
	    if( m_oInfoGrid != null )
	    { 
	    	LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams)m_oInfoGrid.getLayoutParams();
    		lp.height = dm.heightPixels - 45 - 200;
    		m_oInfoGrid.setLayoutParams(lp);
    		 
	    	m_oInfoGrid.setNumColumns(4);
	    	m_oInfoGrid.setColumnWidth(dm.widthPixels/4);
	    	m_oInfoGrid.setHorizontalSpacing(10);
	    	 
	    	String[] str = {"����\n123", "����\n123", "����\n123", "����\n123", "����\n123", "����\n123", "����\n123", "����\n123",
	    			"����\n123", "����\n123", "����\n123", "����\n123", "����\n123", "����\n123", "����\n123", "����\n123", "����\n123", 
	    			"����\n123", "����\n123", "����\n123"}; 
	    	 
	    	mySpinnerAdapter sa = new mySpinnerAdapter( this, str );
	    	m_oInfoGrid.setAdapter(sa);
	    } 

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setAdapter, setNumColumns
	public void create() 
	{ 
		setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
		setGravity(Gravity.CENTER);
		 
		grid = new GridView(context);
		adapter = new DesktopSwitcherAdapter(context);
		 
		workspace = myHome.getInstance().getWorkspace();
		desktopCount = workspace.getDesktopCount();
		 
		columnCount = desktopCount;
		if(columnCount > 4)
			columnCount = 4;
		 
		grid.setNumColumns(columnCount);
		grid.setAdapter(adapter);
		 
		addView(grid);
	} 

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setOverScrollMode, setColumnWidth, setGravity, setNumColumns, setVerticalSpacing
	public GridViewFragment() { 
		super(); 
	} 
 
	public void setUpGridView(GridView gv) {
		gv.setColumnWidth(200);
		gv.setGravity(Gravity.CENTER);
		gv.setOverScrollMode(View.OVER_SCROLL_ALWAYS);
		gv.setNumColumns(GridView.AUTO_FIT);
		gv.setVerticalSpacing(15);
	} 
	 
	@Override 
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	} 
 
	@Override 
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getLayoutParams, setLayoutParams, setColumnWidth, setHorizontalSpacing, setNumColumns
This code example shows how to use the following methods:setGravity, setHorizontalSpacing, setNumColumns, setStretchMode, setVerticalSpacing
		this.mResources = context.getResources();
		init(); 
	} 
	 
	private void init() { 
		mGridView = new GridView(mContext);
		mGridView.setNumColumns(4);
		mGridView.setHorizontalSpacing(10);
		mGridView.setVerticalSpacing(10);
		mGridView.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
		mGridView.setGravity(Gravity.CENTER);
		mGridView.setOnItemClickListener(this);
		setAdapterData(menu_name, menu_image);
	} 
 
	private void setAdapterData(String[] menus_name,String[] menus_image) {
		/** 数据源  **/ 
		ArrayList<HashMap<String, Object>> data = new ArrayList<HashMap<String, Object>>();
		/** 添加数据 **/ 
		 for (int i = 0; i < menus_name.length; i++) {            
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setPadding, setVerticalScrollBarEnabled, setAdapter, setGravity, setNumColumns
		 
		Vector <DataIndicator> currentRow = rows.get(position);
		 
		GridView gridView;
        if (convertView == null) {
        	gridView = new GridView(mContext);
             
            gridView.setVerticalScrollBarEnabled(false);          
 
            gridView.setNumColumns(currentRow.size());
            gridView.setPadding(1,1,1,1);
            //gridView.setLayoutParams(new LayoutParams (LayoutParams.FILL_PARENT, 40)); 
            gridView.setGravity(Gravity.CENTER);
            gridView.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
 
        } else { 
        	gridView = (GridView) convertView;
        } 
 
        DataListItemAdapter itemAdapter = new DataListItemAdapter(mContext, currentRow, false);

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setPadding, setFastScrollEnabled, setAdapter, setColumnWidth, setHorizontalSpacing
This code example shows how to use the following methods:setPadding, setAdapter, setHorizontalSpacing, setNumColumns, setVerticalSpacing
 
		// FrameLayout mFrameLayout = new FrameLayout(this); 
		LayoutParams mLayoutParams_wrap = new LayoutParams(153, 140);
		// mFrameLayout.setLayoutParams(mLayoutParams); 
 
		mGridView = new GridView(this);
		localMainMenuAdapter = new MainMenuAdapter2(this, mList);
		mGridView.setAdapter(localMainMenuAdapter);
		mGridView.setNumColumns(COLUMN_SUM); // 设置3列。
		mGridView.setHorizontalSpacing(1);// 横向间隔
		mGridView.setVerticalSpacing(24);// 纵向间隔
		mGridView.setPadding(6, 4, 6, 0);// 设置填充
		mGridView.setOnItemClickListener(this);
		// mFrameLayout.addView(mGridView, mLayoutParams_wrap); 
		this.mScrollLayout.addView(mGridView, mLayoutParams_wrap);
	} 
 
	@Override 
	public void OnViewChange(int index) {
 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setAdapter, setNumColumns
	@Override 
	public Object instantiateItem( ViewGroup container, int position ) {
 
		List<IngredientInfo> infos = AppContext.ingredientMaps.get( "classid" + ( position + 1 ) );
		RelativeLayout relativeLayout = new RelativeLayout( context );
		GridView gridView = new GridView( context );
		relativeLayout.addView( gridView );
		gridView.setNumColumns( 4 );
		IngredientGridViewAdapter adapter = new IngredientGridViewAdapter( handler, relativeLayout, gridView, context, layoutInflater, infos );
		gridView.setAdapter( adapter );
		container.addView( relativeLayout );
		return relativeLayout;
	} 
 
} 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setPadding, setAdapter, setHorizontalSpacing, setNumColumns, setVerticalSpacing
 
		// FrameLayout mFrameLayout = new FrameLayout(this); 
		LayoutParams mLayoutParams_wrap = new LayoutParams(153, 140);
		// mFrameLayout.setLayoutParams(mLayoutParams); 
 
		mGridView = new GridView(this);
		localMainMenuAdapter = new MainMenuAdapter2(this, mList);
		mGridView.setAdapter(localMainMenuAdapter);
		mGridView.setNumColumns(COLUMN_SUM); // 设置3列。
		mGridView.setHorizontalSpacing(1);// 横向间隔
		mGridView.setVerticalSpacing(24);// 纵向间隔
		mGridView.setPadding(6, 4, 6, 0);// 设置填充
		mGridView.setOnItemClickListener(this);
		// mFrameLayout.addView(mGridView, mLayoutParams_wrap); 
		this.mScrollLayout.addView(mGridView, mLayoutParams_wrap);
	} 
 
	@Override 
	public void OnViewChange(int index) {
 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

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

setNumColumns Method Overview
Set the number of columns in the grid
See Code Examples for other Android GridView Methods: