GridView setGravity - 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 setGravity method.

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) {
Full Snippet Info
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
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++) {            
Full Snippet Info
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: setLayoutParams, setPadding, setGravity, setHorizontalSpacing, setNumColumns
This code example shows how to use the following methods: setLayoutParams, setPadding, setSelector, setGravity, setHorizontalSpacing
		super(context);
 
		mLayout = new LinearLayout(context);
		mLayout.setOrientation(LinearLayout.VERTICAL);
 
		gridView = new GridView(context);
		gridView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,
				LayoutParams.WRAP_CONTENT));
		gridView.setSelector(new ColorDrawable(Color.TRANSPARENT));// 选中的时候为透明色
		gridView.setNumColumns(bodyAdapter.resID.length);
		gridView.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
		gridView.setVerticalSpacing(0);
		gridView.setHorizontalSpacing(0);
		gridView.setPadding(0, 0, 0, 0);
		gridView.setGravity(Gravity.CENTER);
		gridView.setOnItemClickListener(bodyClick);
		//gridView.setBackgroundResource(R.drawable.button); 
		 
		mLayout.addView(gridView);
		// 设置默认项 
		this.setContentView(mLayout);
Full Snippet Info
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: setLayoutParams, setPadding, setSelector, setColumnWidth, setGravity
			convertView = ph.rootView;
			convertView.setTag(ph);
		} else { 
			ph = (PageHolder) convertView.getTag();
		} 
		ph.adapter.resetDataForReuse(ph.gridView, provider, pageIndex);
		ph.gridView.setAdapter(ph.adapter);
		perShowGridConfig(ph.gridView, pageIndex);// 用户可以自定义
		return convertView;
	} 
 
	@Override 
	public void onDataChanged(PageDataProvider<T> provider) {
		if (provider != null) {
			perPageItemCount = provider.getDefaultPerPageItemCount();
		} 
	} 
 
	@Override 
	public void onPageRecycle(View page) {

4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: setLayoutParams, setPadding, setSelector, setGravity, setHorizontalSpacing
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: setLayoutParams, setSelector, setAdapter, setGravity, setHorizontalSpacing
		super(context);
 
		mLayout = new LinearLayout(context);
		mLayout.setOrientation(LinearLayout.VERTICAL);
		// ±êÌâÑ¡ÏîÀ¸ 
		gvTitle = new GridView(context);
		gvTitle.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
				LayoutParams.WRAP_CONTENT));
		gvTitle.setNumColumns(titleAdapter.getCount());
		gvTitle.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
		gvTitle.setVerticalSpacing(1);
		gvTitle.setHorizontalSpacing(1);
		gvTitle.setGravity(Gravity.CENTER);
		gvTitle.setOnItemClickListener(titleClick);
		gvTitle.setAdapter(titleAdapter);
		gvTitle.setSelector(new ColorDrawable(Color.TRANSPARENT));// Ñ¡ÖеÄʱºòΪ͸Ã÷É«
		this.titleAdapter = titleAdapter;
		// ×ÓÑ¡ÏîÀ¸ 
		gvBody = new GridView(context);
		gvBody.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
				LayoutParams.WRAP_CONTENT));
Full Snippet Info
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: setLayoutParams, setSelector, setAdapter, setGravity, setHorizontalSpacing
		super(context);
		 
		layout = new LinearLayout(context);
		layout.setOrientation(LinearLayout.VERTICAL);
		//标题选项栏 
		title = new GridView(context);
        title.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); 
        title.setNumColumns(titleAdapter.getCount());
		title.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
		title.setVerticalSpacing(1);
		title.setHorizontalSpacing(1);
		title.setGravity(Gravity.CENTER);
		title.setOnItemClickListener(titleClick);
		title.setAdapter(titleAdapter);
		title.setSelector(new ColorDrawable(Color.TRANSPARENT));//选中的时候为透明色
		this.titleAdapter=titleAdapter;
		//子选项栏 
		body = new GridView(context);
		body.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
		body.setSelector(new ColorDrawable(Color.TRANSPARENT));//选中的时候为透明色
Full Snippet Info
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related GridView setGravity Questions & Answers:

setGravity Method Overview
Set the gravity for this grid.
See Code Examples for other Android GridView Methods: