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
This code example shows how to use the following methods: getChildAt, getChildCount, getListPaddingTop, getAdapter
                newLastChild.getId());
    } 
     
    @LargeTest 
    public void testShortScroll() { 
        View firstChild = mGridView.getChildAt(0);
        if (firstChild.getTop() < this.mGridView.getListPaddingTop()) {
            firstChild = mGridView.getChildAt(1);
        } 
             
        View lastChild = mGridView.getChildAt(mGridView.getChildCount() - 1);
         
        int lastTop = lastChild.getTop();
         
        TouchUtils.dragViewBy(this, firstChild, Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0,
                ViewConfiguration.getTouchSlop() + 1 + 10);
         
        View newLastChild = mGridView.getChildAt(mGridView.getChildCount() - 1);
         
        assertEquals("View scrolled to wrong position", lastTop, newLastChild.getTop() - 10);

6
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
        lp.height = height;
        lv.setLayoutParams(lp);
    } 
 
    public static void makeGridViewFullSize(GridView gv, int itemHeight, int rowNum) {
        int itemCount = gv.getAdapter().getCount();
        int lines = (int) (itemCount / rowNum);
        if (itemCount % rowNum != 0) {
            lines++;
        } 
        ViewGroup.LayoutParams lp = gv.getLayoutParams();
        lp.height = lines * itemHeight;
        gv.setLayoutParams(lp);
 
    } 
 
    public static int getActionBarHeight() { 
        TypedArray a = context.obtainStyledAttributes(new int[]{ACTIONBAR_HEIGHT});
        int ret = a.getDimensionPixelSize(0, -1);
        a.recycle();
Full Snippet Info
6
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: getHeight, getChildAt, getChildCount, getListPaddingBottom, getAdapter
                mGridView.getHeight() - mGridView.getListPaddingBottom(), lastChild.getBottom());
    } 
     
    @MediumTest 
    public void testPushUpFast() { 
        TouchUtils.dragViewToTop(this, mGridView.getChildAt(mGridView.getChildCount() - 1), 2);
 
        // Nothing should be selected 
        assertEquals("Selection still available after touch", -1,
                mGridView.getSelectedItemPosition());
 
        View lastChild = mGridView.getChildAt(mGridView.getChildCount() - 1);
 
        assertEquals("Last item not the last child in the grid",
                mGridView.getAdapter().getCount() - 1, lastChild.getId());
 
        assertEquals("Last item not at the bottom of the grid",
                mGridView.getHeight() - mGridView.getListPaddingBottom(), lastChild.getBottom());
    } 
 

6
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: setAdapter
	 
	public void setEmotionGridViewAdapter(EmotionsGridAdapter adapter) {
		if (emotionGrid == null) {
			setEmotionGridView(); 
		} 
		emotionGrid.setAdapter(adapter);
	} 
	 
	public void setEmotionGridViewOnItemClickListener(EditMicroBlogEmotionItemClickListener listener) {
		if (emotionGrid == null) {
			setEmotionGridView(); 
		} 
		emotionGrid.setOnItemClickListener(listener);
	} 
	 
	public int getEmotionViewVisibility() { 
		if (llEmotion == null) {
			setLlEmotion(); 
		} 
		return llEmotion.getVisibility();
Full Snippet Info
6
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: invalidateViews
	ColorPickerDialogFragment mFragment = new ColorPickerDialogFragment();
 
	@Override 
	public void onColorSelected(final int color) {
		mCustomizedColor = color;
		mColorsGrid.invalidateViews();
		finishSelecting(color);
	} 
 
	@Override 
	public void onCreate(final Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.set_color); 
		mColorsGrid = (GridView) findViewById(R.id.colors_grid);
 
		final Bundle bundle = savedInstanceState != null ? savedInstanceState : getIntent().getExtras();
 
		mCustomizedColor = bundle != null ? bundle.getInt(Accounts.USER_COLOR, Color.WHITE) : Color.WHITE;
 
		final Resources res = getResources();
Full Snippet Info
6
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: