コード例 #1
0
 private void clearSelect() {
   mMsgListView.clearChoices();
   final int checkedCount = mMsgListView.getCheckedItemCount();
   mSelectionMenu.setTitle(getString(R.string.selected_count, checkedCount));
   if (checkedCount == 0) {
     mActionButton.setEnabled(false);
   }
   mMsgListView.invalidateViews();
 }
コード例 #2
0
 @Override
 public void onItemCheckedStateChanged(
     ActionMode mode, int position, long id, boolean checked) {
   // Get the total of checked items
   final int checkedCount = list.getCheckedItemCount();
   // Set the CAB title according to total checked items
   mode.setTitle(checkedCount + getString(R.string.selected_postfix));
   // Call to the toggle method of the adapter
   adapter.toggleSelection(position);
 }
コード例 #3
0
  @Override
  protected void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);

    if (l.getCheckedItemCount() > 0) {
      mSendMenuItem.setVisible(true);
    } else {
      mSendMenuItem.setVisible(false);
    }
  }
コード例 #4
0
 private void allSelect() {
   int count = mMsgListAdapter.getCount();
   for (int i = 0; i < count; i++) {
     mMsgListView.setItemChecked(i, true);
   }
   final int checkedCount = mMsgListView.getCheckedItemCount();
   mSelectionMenu.setTitle(getString(R.string.selected_count, checkedCount));
   if (checkedCount > 0) {
     mActionButton.setEnabled(true);
   }
   mMsgListView.invalidateViews();
 }
コード例 #5
0
 // change the visibility of the send button (set in menu_recipients.xml) whenever a a friend is
 // selected
 // we create the menu in onCreateOptionsMenu
 @Override
 protected void onListItemClick(ListView l, View v, int position, long id) {
   super.onListItemClick(l, v, position, id);
   // check the number of items that are checked on the list
   if (l.getCheckedItemCount() > 0) {
     // set the menuItem to visible if an item is clicked
     mSendMenuItem.setVisible(true);
   } else {
     // otherwise, if it is 0, then hide the menu item
     mSendMenuItem.setVisible(false);
   }
 }
コード例 #6
0
  public int getCheckedItemCount() {
    ListView listView = mListView;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
      return listView.getCheckedItemCount();
    }

    SparseBooleanArray checkedItems = listView.getCheckedItemPositions();
    int count = 0;
    for (int i = 0, size = checkedItems.size(); i < size; ++i) {
      if (checkedItems.valueAt(i)) {
        count++;
      }
    }
    return count;
  }
コード例 #7
0
ファイル: Sunday.java プロジェクト: NateshR/TaskTable
  @Override
  public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) {
    // TODO Auto-generated method stub
    final int checkedCount = content.getCheckedItemCount();
    switch (checkedCount) {
      case 0:
        mode.setSubtitle(null);
        break;
      case 1:
        mode.setSubtitle("One item selected");

        break;
      default:
        mode.setSubtitle("" + checkedCount);
        break;
    }
  }
コード例 #8
0
 protected boolean onSelectionActionItemClicked(final ActionMode mode, MenuItem item) {
   ListView listView = getListView();
   switch (item.getItemId()) {
     case R.id.blob_descriptor_delete:
       int count = listView.getCheckedItemCount();
       String countStr =
           getResources().getQuantityString(getDeleteConfirmationItemCountResId(), count, count);
       String message = getString(R.string.blob_descriptor_confirm_delete, countStr);
       deleteConfirmationDialog =
           new AlertDialog.Builder(getActivity())
               .setIcon(android.R.drawable.ic_dialog_alert)
               .setTitle("")
               .setMessage(message)
               .setPositiveButton(
                   android.R.string.yes,
                   new DialogInterface.OnClickListener() {
                     @Override
                     public void onClick(DialogInterface dialog, int which) {
                       deleteSelectedItems();
                       mode.finish();
                       deleteConfirmationDialog = null;
                     }
                   })
               .setNegativeButton(android.R.string.no, null)
               .create();
       deleteConfirmationDialog.setOnDismissListener(
           new DialogInterface.OnDismissListener() {
             @Override
             public void onDismiss(DialogInterface dialogInterface) {
               deleteConfirmationDialog = null;
             }
           });
       deleteConfirmationDialog.show();
       return true;
     case R.id.blob_descriptor_select_all:
       int itemCount = listView.getCount();
       for (int i = itemCount - 1; i > -1; --i) {
         listView.setItemChecked(i, true);
       }
       return true;
     default:
       return false;
   }
 }
コード例 #9
0
 private void updateTitle(final ActionMode mode) {
   final ListView listView = getListView();
   if (listView == null || mode == null || getActivity() == null) return;
   final int count = listView.getCheckedItemCount();
   mode.setTitle(getResources().getQuantityString(R.plurals.Nitems_selected, count, count));
 }