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


Java ListAdapter.getItemId方法代码示例

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


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

示例1: getItemId

import android.widget.ListAdapter; //导入方法依赖的package包/类
/**
 * Get the row id associated with the specified position
 * in the list.
 *
 * @param position Position of the item whose data we want
 */
@Override
public long getItemId(int position)
{
	for (ListAdapter piece : pieces)
	{
		int size = piece.getCount();

		if (position < size)
		{
			return (piece.getItemId(position));
		}

		position -= size;
	}

	return (-1);
}
 
开发者ID:ultrasonic,项目名称:ultrasonic,代码行数:24,代码来源:MergeAdapter.java

示例2: getViewForId

import android.widget.ListAdapter; //导入方法依赖的package包/类
public View getViewForId(long itemId) {
    int firstVisiblePosition = getFirstVisiblePosition();
    ListAdapter adapter = getAdapter();
    for (int i = 0; i < getChildCount(); i++) {
        View v = getChildAt(i);
        int position = firstVisiblePosition + i;
        long id = adapter.getItemId(position);
        if (id == itemId) {
            return v;
        }
    }
    return null;
}
 
开发者ID:jpaijh,项目名称:TYT,代码行数:14,代码来源:DynamicGridView.java

示例3: getCheckItemIds

import android.widget.ListAdapter; //导入方法依赖的package包/类
@Deprecated
public long[] getCheckItemIds() {
    if (this.mAdapter != null && this.mAdapter.hasStableIds()) {
        return getCheckedItemIds();
    }
    if (this.mChoiceMode == 0 || this.mCheckStates == null || this.mAdapter == null) {
        return new long[0];
    }
    SparseArrayCompat<Boolean> states = this.mCheckStates;
    int count = states.size();
    long[] ids = new long[count];
    ListAdapter adapter = this.mAdapter;
    int i = 0;
    int checkedCount = 0;
    while (i < count) {
        int checkedCount2;
        if (((Boolean) states.valueAt(i)).booleanValue()) {
            checkedCount2 = checkedCount + 1;
            ids[checkedCount] = adapter.getItemId(states.keyAt(i));
        } else {
            checkedCount2 = checkedCount;
        }
        i++;
        checkedCount = checkedCount2;
    }
    if (checkedCount == count) {
        return ids;
    }
    long[] result = new long[checkedCount];
    System.arraycopy(ids, 0, result, 0, checkedCount);
    return result;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:33,代码来源:HListView.java

示例4: getCheckItemIds

import android.widget.ListAdapter; //导入方法依赖的package包/类
/**
 * 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,代码行数:46,代码来源:HListView.java

示例5: getItemId

import android.widget.ListAdapter; //导入方法依赖的package包/类
/**
 * Get the row id associated with the specified position
 * in the list.
 *
 * @param position Position of the item whose data we want
 */
@Override
public long getItemId(int position) {
    for (ListAdapter piece : getPieces()) {
        int size = piece.getCount();

        if (position < size) {
            return (piece.getItemId(position));
        }

        position -= size;
    }

    return (-1);
}
 
开发者ID:Twelvelines,项目名称:AndroidMuseumBleManager,代码行数:21,代码来源:MergeAdapter.java


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