当前位置: 首页>>代码示例>>Java>>正文


Java AbsListView.CHOICE_MODE_NONE属性代码示例

本文整理汇总了Java中android.widget.AbsListView.CHOICE_MODE_NONE属性的典型用法代码示例。如果您正苦于以下问题:Java AbsListView.CHOICE_MODE_NONE属性的具体用法?Java AbsListView.CHOICE_MODE_NONE怎么用?Java AbsListView.CHOICE_MODE_NONE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.widget.AbsListView的用法示例。


在下文中一共展示了AbsListView.CHOICE_MODE_NONE属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setAdapter

/**
 * {@inheritDoc}
 */
@Override
public void setAdapter(ListAdapter adapter) {
	if (adapter != null) {
		mAdapterHasStableIds = mAdapter.hasStableIds();
		if (mChoiceMode != AbsListView.CHOICE_MODE_NONE
				&& mAdapterHasStableIds && mCheckedIdStates == null) {
			mCheckedIdStates = new LongSparseArray<Integer>();
		}
	}

	if (mCheckStates != null) {
		mCheckStates.clear();
	}

	if (mCheckedIdStates != null) {
		mCheckedIdStates.clear();
	}
}
 
开发者ID:junchenChow,项目名称:exciting-app,代码行数:21,代码来源:AbsHListView.java

示例2: getCheckedItemIds

/**
 * Returns the set of checked items ids. The result is only valid if the
 * choice mode has not been set to {@link #CHOICE_MODE_NONE} and the adapter
 * has stable IDs. ({@link ListAdapter#hasStableIds()} == {@code true})
 * 
 * @return A new array which contains the id of each checked item in the
 *         list.
 */
public long[] getCheckedItemIds() {
	if (mChoiceMode == AbsListView.CHOICE_MODE_NONE
			|| mCheckedIdStates == null || mAdapter == null) {
		return new long[0];
	}

	final LongSparseArray<Integer> idStates = mCheckedIdStates;
	final int count = idStates.size();
	final long[] ids = new long[count];

	for (int i = 0; i < count; i++) {
		ids[i] = idStates.keyAt(i);
	}

	return ids;
}
 
开发者ID:junchenChow,项目名称:exciting-app,代码行数:24,代码来源:AbsHListView.java

示例3: getCheckItemIds

/**
 * Returns the set of checked items ids. The result is only valid if the
 * choice mode has not been set to {@link #CHOICE_MODE_NONE}.
 * 
 * @return A new array which contains the id of each checked item in the
 *         list.
 * 
 * @deprecated Use {@link #getCheckedItemIds()} instead.
 */
@Deprecated
public long[] getCheckItemIds() {
	// Use new behavior that correctly handles stable ID mapping.
	if (mAdapter != null && mAdapter.hasStableIds()) {
		return getCheckedItemIds();
	}

	// Old behavior was buggy, but would sort of work for adapters without
	// stable IDs.
	// Fall back to it to support legacy apps.
	if (mChoiceMode != AbsListView.CHOICE_MODE_NONE && mCheckStates != null && mAdapter != null) {
		final SparseArrayCompat<Boolean> states = mCheckStates;
		final int count = states.size();
		final long[] ids = new long[count];
		final ListAdapter adapter = mAdapter;

		int checkedCount = 0;
		for (int i = 0; i < count; i++) {
			if (states.valueAt(i)) {
				ids[checkedCount++] = adapter.getItemId(states.keyAt(i));
			}
		}

		// Trim array if needed. mCheckStates may contain false values
		// resulting in checkedCount being smaller than count.
		if (checkedCount == count) {
			return ids;
		} else {
			final long[] result = new long[checkedCount];
			System.arraycopy(ids, 0, result, 0, checkedCount);

			return result;
		}
	}
	return new long[0];
}
 
开发者ID:junchenChow,项目名称:exciting-app,代码行数:45,代码来源:HListView.java

示例4: 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

示例5: AbsHListView

public AbsHListView(Context context, AttributeSet attrs, int defStyle) {
	super(context, attrs, defStyle);

	if (LOG_ENABLED) {
		Log.i(LOG_TAG, "defStyle: " + defStyle);
	}

	initAbsListView();

	final Resources.Theme theme = context.getTheme();

	TypedArray array = theme.obtainStyledAttributes(attrs,
			R.styleable.AbsHListView, defStyle, 0);

	Drawable listSelector = null;
	boolean drawSelectorOnTop = false;
	boolean stackFromRight = false;
	boolean scrollingCacheEnabled = true;
	int transcriptMode = TRANSCRIPT_MODE_DISABLED;
	int color = 0;
	boolean smoothScrollbar = true;
	int choiceMode = AbsListView.CHOICE_MODE_NONE;

	if (null != array) {
		listSelector = array
				.getDrawable(R.styleable.AbsHListView_android_listSelector);
		drawSelectorOnTop = array.getBoolean(
				R.styleable.AbsHListView_android_drawSelectorOnTop, false);
		stackFromRight = array.getBoolean(
				R.styleable.AbsHListView_hlv_stackFromRight, false);
		scrollingCacheEnabled = array.getBoolean(
				R.styleable.AbsHListView_android_scrollingCache, true);
		transcriptMode = array.getInt(
				R.styleable.AbsHListView_hlv_transcriptMode,
				TRANSCRIPT_MODE_DISABLED);
		color = array.getColor(
				R.styleable.AbsHListView_android_cacheColorHint, 0);
		smoothScrollbar = array.getBoolean(
				R.styleable.AbsHListView_android_smoothScrollbar, true);
		choiceMode = array.getInt(
				R.styleable.AbsHListView_android_choiceMode,
				AbsListView.CHOICE_MODE_NONE);
		array.recycle();

		if (LOG_ENABLED) {
			////log.d(TAG, "listSelector: " + listSelector);
			////log.d(TAG, "drawSelectorOnTop: " + drawSelectorOnTop);
			////log.d(TAG, "stackFromRight: " + stackFromRight);
			////log.d(TAG, "scrollingCacheEnabled: " + scrollingCacheEnabled);
			////log.d(TAG, "transcriptMode: " + transcriptMode);
			////log.d(TAG, "smoothScrollbar: " + smoothScrollbar);
			////log.d(TAG, "choiceMode: " + choiceMode);
		}
	}

	if (listSelector != null) {
		setSelector(listSelector);
	}

	mDrawSelectorOnTop = drawSelectorOnTop;
	setStackFromRight(stackFromRight);
	setScrollingCacheEnabled(scrollingCacheEnabled);
	setTranscriptMode(transcriptMode);
	setCacheColorHint(color);
	setSmoothScrollbarEnabled(smoothScrollbar);
	setChoiceMode(choiceMode);
}
 
开发者ID:junchenChow,项目名称:exciting-app,代码行数:67,代码来源:AbsHListView.java

示例6: isItemChecked

/**
 * Returns the checked state of the specified position. The result is only
 * valid if the choice mode has been set to {@link #CHOICE_MODE_SINGLE} or
 * {@link #CHOICE_MODE_MULTIPLE}.
 * 
 * @param position
 *            The item whose checked state to return
 * @return The item's checked state or <code>false</code> if choice mode is
 *         invalid
 * 
 * @see #setChoiceMode(int)
 */
public boolean isItemChecked(int position) {
	if (mChoiceMode != AbsListView.CHOICE_MODE_NONE && mCheckStates != null) {
		return mCheckStates.get(position, false);
	}

	return false;
}
 
开发者ID:junchenChow,项目名称:exciting-app,代码行数:19,代码来源:AbsHListView.java

示例7: getCheckedItemPositions

/**
 * Returns the set of checked items in the list. The result is only valid if
 * the choice mode has not been set to {@link #CHOICE_MODE_NONE}.
 * 
 * @return A SparseBooleanArray which will return true for each call to
 *         get(int position) where position is a position in the list, or
 *         <code>null</code> if the choice mode is set to
 *         {@link #CHOICE_MODE_NONE}.
 */
public SparseArrayCompat<Boolean> getCheckedItemPositions() {
	if (mChoiceMode != AbsListView.CHOICE_MODE_NONE) {
		return mCheckStates;
	}
	return null;
}
 
开发者ID:junchenChow,项目名称:exciting-app,代码行数:15,代码来源:AbsHListView.java


注:本文中的android.widget.AbsListView.CHOICE_MODE_NONE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。