Android GridView - top ranked examples from Open Source projects

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

This code example shows how to use the following methods: getLayoutParams, setLayoutParams, getAdapter, getNumColumns
		lp.height = height;
		lv.setLayoutParams(lp);
	} 
 
	public static void makeGridViewFullSize(GridView gv, int itemHeight) {
		int itemCount = gv.getAdapter().getCount();
		int columns = gv.getNumColumns();
		int lines = (int) (itemCount / columns);
		if (itemCount % columns != 0) {
			lines++;
		} 
		ViewGroup.LayoutParams lp = gv.getLayoutParams();
		lp.height = lines * itemHeight;
		gv.setLayoutParams(lp);
 
	} 
} 
Full Snippet Info
8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: setVisibility, setAdapter
 
    @Override 
    public void onNewPhotos(List<FeedItem> photos) {
        mAdapter = new PhotosListAdapter(getSherlockActivity());
        mAdapter.fillWithItems(photos);
        mGridView.setAdapter(mAdapter);
        mAdapter.notifyDataSetChanged();
 
        mProgress.setVisibility(GONE);
        mGridView.setVisibility(VISIBLE);
    } 
 
    public GridView getGridView() {
        return mGridView;
    } 
 
    @Override 
    public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
        getPhotoActivity().showDetailWithSelection(i);
    } 
Full Snippet Info
8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: setOnScrollListener, setAdapter, setOnItemClickListener
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getTop, getChildAt, getChildCount
        assertEquals("Wrong view in first position", 0, newFirstChild.getId());
    } 
     
    @LargeTest 
    public void testLongScroll() { 
        View lastChild = mGridView.getChildAt(mGridView.getChildCount() - 1);
         
        int lastTop = lastChild.getTop();
         
        int distance = TouchUtils.dragViewToY(this, lastChild, Gravity.TOP | Gravity.LEFT,
                mGridView.getTop());
         
        assertEquals("View scrolled to wrong position", 
                lastTop - (distance - ViewConfiguration.getTouchSlop() - 1), lastChild.getTop());
    } 
     
    @LargeTest 
    public void testManyScrolls() { 
        int originalCount = mGridView.getChildCount();
         
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getLayoutParams, setLayoutParams, getAdapter, getNumColumns
		lp.height = height;
		lv.setLayoutParams(lp);
	} 
 
	public static void makeGridViewFullSize(GridView gv, int itemHeight) {
		int itemCount = gv.getAdapter().getCount();
		int columns = gv.getNumColumns();
		int lines = (int) (itemCount / columns);
		if (itemCount % columns != 0) {
			lines++;
		} 
		ViewGroup.LayoutParams lp = gv.getLayoutParams();
		lp.height = lines * itemHeight;
		gv.setLayoutParams(lp);
 
	} 
} 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

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: