當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。