android.widget.GridView.getChildCount()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(5.5k)|赞(0)|评价(0)|浏览(112)

本文整理了Java中android.widget.GridView.getChildCount()方法的一些代码示例,展示了GridView.getChildCount()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GridView.getChildCount()方法的具体详情如下:
包路径:android.widget.GridView
类名称:GridView
方法名:getChildCount

GridView.getChildCount介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

final GridView imageContainer = // your GridView
imageContainer.getViewTreeObserver().addOnGlobalLayoutListener( new OnGlobalLayoutListener() 
      {
      @Override
      public void onGlobalLayout() 
        {
        imageContainer.getViewTreeObserver().removeGlobalOnLayoutListener( this );
        View lastChild = imageContainer.getChildAt( imageContainer.getChildCount() - 1 );
        imageContainer.setLayoutParams( new LinearLayout.LayoutParams( LayoutParams.FILL_PARENT, lastChild.getBottom() ) );
        }
      });

代码示例来源:origin: stackoverflow.com

private void checkGridView(GridView gridView) {
  for (int i = 0; i < gridView.getChildCount() ; i++ ){
    View v = gridView.getChildAt(i);
    CheckBox checkBox = (CheckBox) v.findViewById(R.id.custom_adapter_add_checkbox);
    boolean itemChecked = checkBox.isChecked();
  }
}

代码示例来源:origin: chengzichen/KrGallery

@Override
public void willSwitchFromPhoto(FileLocation fileLocation, int index) {
  int count = listView.getChildCount();
  for (int a = 0; a < count; a++) {
    View view = listView.getChildAt(a);

代码示例来源:origin: chengzichen/KrGallery

private PhotoPickerPhotoCell getCellForIndex(int index) {
  int count = listView.getChildCount();
  for (int a = 0; a < count; a++) {
    View view = listView.getChildAt(a);
    if (view instanceof PhotoPickerPhotoCell) {
      PhotoPickerPhotoCell cell = (PhotoPickerPhotoCell) view;
      int num = (Integer) cell.photoImage.getTag();
      if (selectedAlbum != null) {
        if (num < 0 || num >= selectedAlbum.photos.size()) {
          continue;
        }
      } else {
        ArrayList<MediaController.SearchImage> array;
        if (searchResult.isEmpty() && lastSearchString == null) {
          array = recentImages;
        } else {
          array = searchResult;
        }
        if (num < 0 || num >= array.size()) {
          continue;
        }
      }
      if (num == index) {
        return cell;
      }
    }
  }
  return null;
}

代码示例来源:origin: fire3/sailorcast

@Override
  public void onScroll(AbsListView view, int firstVisibleItem,
             int visibleItemCount, int totalItemCount) {
    boolean enable = false;
    if (mGrid != null && mGrid.getChildCount() > 0) {
      // check if the first item of the list is visible
      boolean firstItemVisible = mGrid.getFirstVisiblePosition() == 0;
      // check if the top of the first item is visible
      boolean topOfFirstItemVisible = mGrid.getChildAt(0).getTop() == 0;
      // enabling or disabling the refresh layout
      enable = firstItemVisible && topOfFirstItemVisible;
    }
    mSwipeContainer.setEnabled(enable);
  }
});

代码示例来源:origin: fire3/sailorcast

@Override
  public void onScroll(AbsListView view, int firstVisibleItem,
             int visibleItemCount, int totalItemCount) {
    boolean enable = false;
    if (mGrid != null && mGrid.getChildCount() > 0) {
      // check if the first item of the list is visible
      boolean firstItemVisible = mGrid.getFirstVisiblePosition() == 0;
      // check if the top of the first item is visible
      boolean topOfFirstItemVisible = mGrid.getChildAt(0).getTop() == 0;
      // enabling or disabling the refresh layout
      enable = firstItemVisible && topOfFirstItemVisible;
    }
    mSwipeContainer.setEnabled(enable);
  }
});

代码示例来源:origin: reloZid/android-anuto

private void updateArrowVisibility() {
    if (grid_maps.getChildCount() <= 0) {
      arrow_up.setVisibility(View.INVISIBLE);
      arrow_down.setVisibility(View.INVISIBLE);
      return;
    }

    if (grid_maps.getFirstVisiblePosition() == 0) {
      arrow_up.setVisibility(grid_maps.getChildAt(0).getTop() < -10 ? View.VISIBLE : View.INVISIBLE);
    } else {
      arrow_up.setVisibility(grid_maps.getFirstVisiblePosition() > 0 ? View.VISIBLE : View.INVISIBLE);
    }

    if (grid_maps.getLastVisiblePosition() == mAdapter.getCount() - 1) {
      arrow_down.setVisibility(grid_maps.getChildAt(grid_maps.getChildCount() - 1).getBottom() > grid_maps.getHeight() + 10 ? View.VISIBLE : View.INVISIBLE);
    } else {
      arrow_down.setVisibility(grid_maps.getLastVisiblePosition() < mAdapter.getCount() - 1 ? View.VISIBLE : View.INVISIBLE);
    }
  }
}

代码示例来源:origin: stackoverflow.com

public void getAllValues() {
   View parentView = null;
   int temp = 0;
   int getTotal = 0;
   int totQuan = 0;
   int quan = 0;
   for (int i = 0; i < list.getCount(); i++) {
     parentView = getViewByPosition(i, list);
     String getString = ((TextView) parentView
         .findViewById(R.id.totalPrice)).getText().toString();
     getTotal = Integer.parseInt(getString);
     temp = temp + getTotal;
     totQuan = Integer.parseInt(((TextView) parentView
         .findViewById(R.id.counter)).getText().toString());
     quan = quan + totQuan;
   }
   setTotalAmount(String.valueOf(temp), String.valueOf(quan));
 }
 public View getViewByPosition(int pos, GridView listView) {
   final int firstListItemPosition = listView.getFirstVisiblePosition();
   final int lastListItemPosition = firstListItemPosition
       + listView.getChildCount() - 1;
   if (pos < firstListItemPosition || pos > lastListItemPosition) {
     return listView.getAdapter().getView(pos, null, listView);
   } else {
     final int childIndex = pos - firstListItemPosition;
     return listView.getChildAt(childIndex);
   }
 }

代码示例来源:origin: stackoverflow.com

@Override
public boolean onTouch(View v, MotionEvent event) {
  for(int i =0; i< layout.getChildCount(); i++){
    View view = layout.getChildAt(i);
    Rect outRect = new Rect(view.getLeft(), view.getTop(), view.getRight(), view.getBottom());

代码示例来源:origin: chengzichen/KrGallery

int count = listView.getChildCount();
for (int a = 0; a < count; a++) {
  View view = listView.getChildAt(a);

代码示例来源:origin: sphinx02/AppStarter

if(mSettings.getAutoSelectFirstIcon() && mGridView.getChildCount() > 0)

代码示例来源:origin: stackoverflow.com

super.onDestroy();
final GridView grid = sdcardImages;
final int count = grid.getChildCount();
ImageView v = null;
for (int i = 0; i < count; i++) {

代码示例来源:origin: stackoverflow.com

return view.getChildCount() > 0 &&
    (view.getFirstVisiblePosition() > 0
        || view.getChildAt(0).getTop() < view.getPaddingTop());

代码示例来源:origin: stackoverflow.com

final int lastViewIndex = mGrid.getChildCount() - 1;
final int lastPos = firstPos + lastViewIndex;

相关文章

GridView类方法