當前位置: 首頁>>代碼示例>>Java>>正文


Java AbsListView.CHOICE_MODE_MULTIPLE_MODAL屬性代碼示例

本文整理匯總了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);
			}
		}
	}
}
 
開發者ID:junchenChow,項目名稱:exciting-app,代碼行數:44,代碼來源:AbsHListView.java

示例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;
}
 
開發者ID:junchenChow,項目名稱:exciting-app,代碼行數:30,代碼來源:AbsHListView.java

示例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();
}
 
開發者ID:junchenChow,項目名稱:exciting-app,代碼行數:58,代碼來源:AbsHListView.java


注:本文中的android.widget.AbsListView.CHOICE_MODE_MULTIPLE_MODAL屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。