本文整理汇总了Java中android.widget.AbsListView.CHOICE_MODE_MULTIPLE_MODAL属性的典型用法代码示例。如果您正苦于以下问题:Java AbsListView.CHOICE_MODE_MULTIPLE_MODAL属性的具体用法?Java AbsListView.CHOICE_MODE_MULTIPLE_MODAL怎么用?Java AbsListView.CHOICE_MODE_MULTIPLE_MODAL使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.widget.AbsListView
的用法示例。
在下文中一共展示了AbsListView.CHOICE_MODE_MULTIPLE_MODAL属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setChoiceMode
/**
* Defines the choice behavior for the List. By default, Lists do not have
* any choice behavior ({@link #CHOICE_MODE_NONE}). By setting the
* choiceMode to {@link #CHOICE_MODE_SINGLE}, the List allows up to one item
* to be in a chosen state. By setting the choiceMode to
* {@link #CHOICE_MODE_MULTIPLE}, the list allows any number of items to be
* chosen.
*
* @param choiceMode
* One of {@link #CHOICE_MODE_NONE}, {@link #CHOICE_MODE_SINGLE},
* or {@link #CHOICE_MODE_MULTIPLE}
*/
@TargetApi(11)
public void setChoiceMode(int choiceMode) {
mChoiceMode = choiceMode;
if (android.os.Build.VERSION.SDK_INT >= 11) {
if (mChoiceActionMode != null) {
if (android.os.Build.VERSION.SDK_INT >= 11) {
((ActionMode) mChoiceActionMode).finish();
}
mChoiceActionMode = null;
}
}
if (mChoiceMode != AbsListView.CHOICE_MODE_NONE) {
if (mCheckStates == null) {
mCheckStates = new SparseArrayCompat<Boolean>();
}
if (mCheckedIdStates == null && mAdapter != null
&& mAdapter.hasStableIds()) {
mCheckedIdStates = new LongSparseArray<Integer>();
}
// Modal multi-choice mode only has choices when the mode is active.
// Clear them.
if (android.os.Build.VERSION.SDK_INT >= 11) {
if (mChoiceMode == AbsListView.CHOICE_MODE_MULTIPLE_MODAL) {
clearChoices();
setLongClickable(true);
}
}
}
}
示例2: performLongPress
boolean performLongPress(final View child, final int longPressPosition,
final long longPressId) {
// CHOICE_MODE_MULTIPLE_MODAL takes over long press.
if (android.os.Build.VERSION.SDK_INT >= 11) {
if (mChoiceMode == AbsListView.CHOICE_MODE_MULTIPLE_MODAL) {
if (mChoiceActionMode == null
&& (mChoiceActionMode = startActionMode((MultiChoiceModeWrapper) mMultiChoiceModeCallback)) != null) {
setItemChecked(longPressPosition, true);
performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
}
return true;
}
}
boolean handled = false;
if (mOnItemLongClickListener != null) {
handled = mOnItemLongClickListener.onItemLongClick(
AbsHListView.this, child, longPressPosition, longPressId);
}
if (!handled) {
mContextMenuInfo = createContextMenuInfo(child, longPressPosition,
longPressId);
handled = super.showContextMenuForChild(AbsHListView.this);
}
if (handled) {
performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
}
return handled;
}
示例3: onRestoreInstanceState
@Override
public void onRestoreInstanceState(Parcelable state) {
if (LOG_ENABLED) {
Log.i(TAG, "onRestoreInstanceState");
}
SavedState ss = (SavedState) state;
super.onRestoreInstanceState(ss.getSuperState());
mDataChanged = true;
mSyncWidth = ss.width;
if (ss.selectedId >= 0) {
mNeedSync = true;
mPendingSync = ss;
mSyncColId = ss.selectedId;
mSyncPosition = ss.position;
mSpecificLeft = ss.viewLeft;
mSyncMode = SYNC_SELECTED_POSITION;
} else if (ss.firstId >= 0) {
setSelectedPositionInt(INVALID_POSITION);
// Do this before setting mNeedSync since setNextSelectedPosition
// looks at mNeedSync
setNextSelectedPositionInt(INVALID_POSITION);
mSelectorPosition = INVALID_POSITION;
mNeedSync = true;
mPendingSync = ss;
mSyncColId = ss.firstId;
mSyncPosition = ss.position;
mSpecificLeft = ss.viewLeft;
mSyncMode = SYNC_FIRST_POSITION;
}
if (LOG_ENABLED) {
////log.d(TAG, "checkState: " + ss.checkState);
////log.d(TAG, "checkIdState: " + ss.checkIdState);
}
if (ss.checkState != null) {
mCheckStates = ss.checkState;
}
if (ss.checkIdState != null) {
mCheckedIdStates = ss.checkIdState;
}
mCheckedItemCount = ss.checkedItemCount;
if (android.os.Build.VERSION.SDK_INT >= 11) {
if (ss.inActionMode
&& mChoiceMode == AbsListView.CHOICE_MODE_MULTIPLE_MODAL
&& mMultiChoiceModeCallback != null) {
mChoiceActionMode = startActionMode((MultiChoiceModeWrapper) mMultiChoiceModeCallback);
}
}
requestLayout();
}