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

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

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

GridView.getCheckedItemCount介绍

暂无

代码示例

代码示例来源:origin: THEONE10211024/ApiDemos

public void onItemCheckedStateChanged(ActionMode mode, int position, long id,
    boolean checked) {
  int selectCount = mGrid.getCheckedItemCount();
  switch (selectCount) {
  case 1:
    mode.setSubtitle("One item selected");
    break;
  default:
    mode.setSubtitle("" + selectCount + " items selected");
    break;
  }
}

代码示例来源:origin: qiubiteme/android_api_demos

public void onItemCheckedStateChanged(ActionMode mode, int position, long id,
    boolean checked) {
  int selectCount = mGrid.getCheckedItemCount();
  switch (selectCount) {
  case 1:
    mode.setSubtitle("One item selected");
    break;
  default:
    mode.setSubtitle("" + selectCount + " items selected");
    break;
  }
}

代码示例来源:origin: SimonMarquis/Android-PreferencesManager

@Override
public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) {
  ((PreferenceAdapter) gridView.getAdapter()).itemCheckedStateChanged(position, checked);
  mode.setTitle(Html.fromHtml("<b>" + gridView.getCheckedItemCount() + "</b>"));
}

代码示例来源:origin: googlecreativelab/lipswap

@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
  ChooserAdapter adapter = mWeakActivity.get().getChooserAdapter();
  switch (item.getItemId()) {
    case R.id.action_share:
      Intent shareIntent = AndroidUtils.getShareIntent(item.getActionView().getContext(),
          adapter.getItem(
              (int) mGridView.getCheckedItemIds()[0]
              //first object since we can only have one selected at a time
          ),
          null //insert "Made by Lip Flip?"
      );
      mWeakActivity.get().startActivity(shareIntent);
      break;
    case R.id.action_delete:
      Log.d(TAG, "onActionItemClicked(){delete}"
          + " num: " + mGridView.getCheckedItemCount()
          + " ids: " + Arrays.toString(mGridView.getCheckedItemIds()));
      mWeakActivity.get().deleteItems(mGridView.getCheckedItemIds(), mode);
      //finish mode regardless of outcome...? bad idea?
      mode.finish();
      break;
  }
  return false;
}

代码示例来源:origin: fasteque/rgb-tool

public void onItemCheckedStateChanged(ActionMode mode, int position,
                     long id, boolean checked) {
    int selectCount = mGridView.getCheckedItemCount();
    switch (selectCount) {
      case 1:
        mode.setSubtitle(getString(R.string.rgbtool_gallery_context_menu_subtitle));
        break;
      default:
        mode.setSubtitle(getString(R.string.rgbtool_gallery_context_menu_subtitle_more, selectCount));
        break;
    }
  }
}

代码示例来源:origin: SimonMarquis/Android-PreferencesManager

@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
  switch (item.getItemId()) {
    case R.id.action_delete:
      ((PreferenceAdapter) gridView.getAdapter()).deleteSelection();
      Utils.savePreferences(preferenceFile, mFile, mPackageName, getActivity());
      ((PreferenceAdapter) gridView.getAdapter()).notifyDataSetChanged();
      mode.finish();
      return true;
    case R.id.action_select_all:
      boolean check = gridView.getCheckedItemCount() != gridView.getCount();
      for (int i = 0; i < gridView.getCount(); i++) {
        gridView.setItemChecked(i, check);
      }
      return true;
    default:
      return false;
  }
}

相关文章

GridView类方法