update Cell View in GridView - Android android.widget

Android examples for android.widget:GridView

Description

update Cell View in GridView

Demo Code

import android.view.View;
import android.widget.GridView;

public class Main {

  public static void updateCellView(GridView grid, Object object) {
    int start = grid.getFirstVisiblePosition();
    for (int i = start, j = grid.getLastVisiblePosition(); i <= j; i++) {
      if (object == grid.getItemAtPosition(i)) {
        View view = grid.getChildAt(i - start);
        grid.getAdapter().getView(i, view, grid);
        break;/*from   w  w  w. j a  va2  s.  c om*/
      }
    }
  }

  public static void updateCellView(GridView grid, int position) {
    View view = grid.getChildAt(position);
    grid.getAdapter().getView(position, view, grid);
  }

}

Related Tutorials