holder.bottomText.setText(songItem.getBottomText()); if(listView.isItemChecked(position)){ holder.button_repeat.setVisibility(View.VISIBLE); holder.button_repeat.setTag(position);
@Override public void onClick(final View v) { final int position = mCurrentView.getPositionForView(v); if (position != ListView.INVALID_POSITION) { int count = mCurrentView.getCheckedItemCount(); switch (v.getId()) { case android.R.id.icon: if (count == 0) { ActionMode mChoiceActionMode = null; if (mChoiceActionMode == null && (mChoiceActionMode = mCurrentView.startActionMode(mMultiListener)) != null) { mCurrentView.setItemChecked(position, true); mCurrentView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); } } else { mCurrentView.setItemChecked(position, !mCurrentView.isItemChecked(position)); mCurrentView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); } break; case R.id.button_popup: v.post(new Runnable() { @Override public void run() { showPopupMenu(v, position); } }); break; } } } }
@Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) { // Check to see what the new checked state is, and then notify the listener final boolean checked = mListView.isItemChecked(position); mListener.onItemCheckedStateChanged(mActionMode, position, id, checked); boolean hasCheckedItem = checked; // Check to see if we have any checked items if (!hasCheckedItem) { SparseBooleanArray checkedItemPositions = mListView.getCheckedItemPositions(); if (checkedItemPositions != null) { // Iterate through the SparseBooleanArray to see if there is a checked item int i = 0; while (!hasCheckedItem && i < checkedItemPositions.size()) { hasCheckedItem = checkedItemPositions.valueAt(i++); } } } // If we don't have any checked items, finish the action mode if (!hasCheckedItem) { mActionMode.finish(); } } @Override