本文整理汇总了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);
}
示例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;
}
示例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;
}
示例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];
}
示例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);
}