本文整理了Java中android.widget.ExpandableListView.getPackedPositionChild()
方法的一些代码示例,展示了ExpandableListView.getPackedPositionChild()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ExpandableListView.getPackedPositionChild()
方法的具体详情如下:
包路径:android.widget.ExpandableListView
类名称:ExpandableListView
方法名:getPackedPositionChild
暂无
代码示例来源:origin: androidquery/androidquery
int child = ExpandableListView.getPackedPositionChild(packed);
代码示例来源:origin: thoughtbot/expandable-recycler-view
static ExpandableListPosition obtainPosition(long packedPosition) {
if (packedPosition == ExpandableListView.PACKED_POSITION_VALUE_NULL) {
return null;
}
ExpandableListPosition elp = getRecycledOrCreate();
elp.groupPos = ExpandableListView.getPackedPositionGroup(packedPosition);
if (ExpandableListView.getPackedPositionType(packedPosition) ==
ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
elp.type = CHILD;
elp.childPos = ExpandableListView.getPackedPositionChild(packedPosition);
} else {
elp.type = GROUP;
}
return elp;
}
代码示例来源:origin: THEONE10211024/ApiDemos
@Override
public boolean onContextItemSelected(MenuItem item) {
ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) item.getMenuInfo();
String title = ((TextView) info.targetView).getText().toString();
int type = ExpandableListView.getPackedPositionType(info.packedPosition);
if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
int groupPos = ExpandableListView.getPackedPositionGroup(info.packedPosition);
int childPos = ExpandableListView.getPackedPositionChild(info.packedPosition);
Toast.makeText(this, title + ": Child " + childPos + " clicked in group " + groupPos,
Toast.LENGTH_SHORT).show();
return true;
} else if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
int groupPos = ExpandableListView.getPackedPositionGroup(info.packedPosition);
Toast.makeText(this, title + ": Group " + groupPos + " clicked", Toast.LENGTH_SHORT).show();
return true;
}
return false;
}
代码示例来源:origin: qiubiteme/android_api_demos
@Override
public boolean onContextItemSelected(MenuItem item) {
ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) item.getMenuInfo();
String title = ((TextView) info.targetView).getText().toString();
int type = ExpandableListView.getPackedPositionType(info.packedPosition);
if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
int groupPos = ExpandableListView.getPackedPositionGroup(info.packedPosition);
int childPos = ExpandableListView.getPackedPositionChild(info.packedPosition);
Toast.makeText(this, title + ": Child " + childPos + " clicked in group " + groupPos,
Toast.LENGTH_SHORT).show();
return true;
} else if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
int groupPos = ExpandableListView.getPackedPositionGroup(info.packedPosition);
Toast.makeText(this, title + ": Group " + groupPos + " clicked", Toast.LENGTH_SHORT).show();
return true;
}
return false;
}
代码示例来源:origin: lucid-lynxz/BlogSamples
@Override
public void onScroll(AbsListView view, int firstVisibleItem,int visibleItemCount, int totalItemCount) {
final long flatPos = getExpandableListPosition(firstVisibleItem);
int groupPosition = ExpandableListView.getPackedPositionGroup(flatPos);
int childPosition = ExpandableListView.getPackedPositionChild(flatPos);
configureHeaderView(groupPosition, childPosition);
}
代码示例来源:origin: xiangzhihong/gpuImage
static ExpandableHListPosition obtainPosition(long packedPosition) {
if (packedPosition == ExpandableListView.PACKED_POSITION_VALUE_NULL) {
return null;
}
ExpandableHListPosition elp = getRecycledOrCreate();
elp.groupPos = ExpandableListView.getPackedPositionGroup(packedPosition);
if (ExpandableListView.getPackedPositionType(packedPosition) ==
ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
elp.type = CHILD;
elp.childPos = ExpandableListView.getPackedPositionChild(packedPosition);
} else {
elp.type = GROUP;
}
return elp;
}
代码示例来源:origin: SecUSo/privacy-friendly-todo-list
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
int groupPosition = ExpandableListView.getPackedPositionGroup(id);
if (ExpandableListView.getPackedPositionType(id) == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
int childPosition = ExpandableListView.getPackedPositionChild(id);
taskAdapter.setLongClickedSubTaskByPos(groupPosition, childPosition);
} else {
taskAdapter.setLongClickedTaskByPos(groupPosition);
}
return false;
}
代码示例来源:origin: lucid-lynxz/BlogSamples
@Override
protected void onLayout(boolean changed, int left, int top, int right,int bottom) {
super.onLayout(changed, left, top, right, bottom);
final long flatPostion = getExpandableListPosition(getFirstVisiblePosition());
final int groupPos = ExpandableListView.getPackedPositionGroup(flatPostion);
final int childPos = ExpandableListView.getPackedPositionChild(flatPostion);
int state = mAdapter.getHeaderState(groupPos, childPos);
if (mHeaderView != null && mAdapter != null && state != mOldState) {
mOldState = state;
mHeaderView.layout(0, 0, mHeaderViewWidth, mHeaderViewHeight);
}
configureHeaderView(groupPos, childPos);
}
代码示例来源:origin: SecUSo/privacy-friendly-todo-list
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
int groupPosition = ExpandableListView.getPackedPositionGroup(id);
if (ExpandableListView.getPackedPositionType(id) == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
int childPosition = ExpandableListView.getPackedPositionChild(id);
expandableTodoTaskAdapter.setLongClickedSubTaskByPos(groupPosition, childPosition);
} else {
expandableTodoTaskAdapter.setLongClickedTaskByPos(groupPosition);
}
registerForContextMenu(lv);
return false;
}
});
代码示例来源:origin: SecUSo/privacy-friendly-todo-list
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
int groupPosition = ExpandableListView.getPackedPositionGroup(id);
if (ExpandableListView.getPackedPositionType(id) == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
int childPosition = ExpandableListView.getPackedPositionChild(id);
expandableTodoTaskAdapter.setLongClickedSubTaskByPos(groupPosition, childPosition);
} else {
expandableTodoTaskAdapter.setLongClickedTaskByPos(groupPosition);
}
registerForContextMenu(exLv);
return false;
}
});
代码示例来源:origin: gigabytedevelopers/FireFiles
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
int itemType = ExpandableListView.getPackedPositionType(id);
int childPosition;
int groupPosition;
if ( itemType == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
childPosition = ExpandableListView.getPackedPositionChild(id);
groupPosition = ExpandableListView.getPackedPositionGroup(id);
final Item item = (Item) mAdapter.getChild(groupPosition, childPosition);
if (item instanceof AppItem) {
showAppDetails(((AppItem) item).info);
return true;
} else if (item instanceof BookmarkItem) {
removeBookark((BookmarkItem)item);
return true;
} else {
return false;
}
} else if(itemType == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
groupPosition = ExpandableListView.getPackedPositionGroup(id);
return false;
} else {
return false;
}
}
};
代码示例来源:origin: it.tidalwave.bluebill/bluebill-mobile-android
final int childPosition = ExpandableListView.getPackedPositionChild(info.packedPosition);
final ObservationItem observationItem = controller.getListAdapter().getChild(groupPosition, childPosition);
代码示例来源:origin: nailperry-zd/LazierTracker
private static String buildAdapterViewItemIndex(View child, ViewGroup group) {
int index = ((AdapterView) group).getPositionForView(child);
// ExpandableListView
if (group instanceof ExpandableListView) {
StringBuilder element = new StringBuilder();
String exListIndicator = "";
ExpandableListView _group = (ExpandableListView) group;
long l = _group.getExpandableListPosition(index);
int groupIndex;
if (ExpandableListView.getPackedPositionType(l) == ExpandableListView.PACKED_POSITION_TYPE_NULL) {
if (index < _group.getHeaderViewsCount()) {
exListIndicator = "[header:" + index + "]";// header
} else {
groupIndex = index - (_group.getCount() - _group.getFooterViewsCount());
exListIndicator = "[footer:" + groupIndex + "]";// footer
}
} else {
groupIndex = ExpandableListView.getPackedPositionGroup(l);
int childIndex = ExpandableListView.getPackedPositionChild(l);
if (childIndex != -1) {
exListIndicator = "[group:" + groupIndex + ",child:" + childIndex + "]";// group/child
} else {
exListIndicator = "[group:" + groupIndex + "]";// group
}
}
Log.d("ExpandableListViewItem", "@index = " + index + ", @exListIndicator = " + exListIndicator);
return exListIndicator;
}
return "[" + index + "]";
}
代码示例来源:origin: derry/delion
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
// Would prefer to have this context menu view managed internal to RecentTabsGroupView
// Unfortunately, setting either onCreateContextMenuListener or onLongClickListener
// disables the native onClick (expand/collapse) behaviour of the group view.
ExpandableListView.ExpandableListContextMenuInfo info =
(ExpandableListView.ExpandableListContextMenuInfo) menuInfo;
int type = ExpandableListView.getPackedPositionType(info.packedPosition);
int groupPosition = ExpandableListView.getPackedPositionGroup(info.packedPosition);
if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
mAdapter.getGroup(groupPosition).onCreateContextMenuForGroup(menu, mActivity);
} else if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
int childPosition = ExpandableListView.getPackedPositionChild(info.packedPosition);
mAdapter.getGroup(groupPosition).onCreateContextMenuForChild(childPosition, menu,
mActivity);
}
}
代码示例来源:origin: com.googlecode.android-query/android-query
int child = ExpandableListView.getPackedPositionChild(packed);
代码示例来源:origin: PrivacyApps/document-viewer
protected Object getContextMenuSource(final View v, final ContextMenuInfo menuInfo) {
Object source = null;
if (menuInfo instanceof AdapterContextMenuInfo) {
final AbsListView list = (AbsListView) v;
final AdapterContextMenuInfo mi = (AdapterContextMenuInfo) menuInfo;
source = list.getAdapter().getItem(mi.position);
} else if (menuInfo instanceof ExpandableListContextMenuInfo) {
final ExpandableListView list = (ExpandableListView) v;
final ExpandableListAdapter adapter = list.getExpandableListAdapter();
final ExpandableListContextMenuInfo mi = (ExpandableListContextMenuInfo) menuInfo;
final long pp = mi.packedPosition;
final int group = ExpandableListView.getPackedPositionGroup(pp);
final int child = ExpandableListView.getPackedPositionChild(pp);
if (child >= 0) {
source = adapter.getChild(group, child);
} else {
source = adapter.getGroup(group);
}
}
return source;
}
代码示例来源:origin: PrivacyApps/document-viewer
protected Object getContextMenuSource(final View v, final ContextMenuInfo menuInfo) {
Object source = null;
if (menuInfo instanceof AdapterContextMenuInfo) {
final AbsListView list = (AbsListView) v;
final AdapterContextMenuInfo mi = (AdapterContextMenuInfo) menuInfo;
source = list.getAdapter().getItem(mi.position);
} else if (menuInfo instanceof ExpandableListContextMenuInfo) {
final ExpandableListView list = (ExpandableListView) v;
final ExpandableListAdapter adapter = list.getExpandableListAdapter();
final ExpandableListContextMenuInfo mi = (ExpandableListContextMenuInfo) menuInfo;
final long pp = mi.packedPosition;
final int group = ExpandableListView.getPackedPositionGroup(pp);
final int child = ExpandableListView.getPackedPositionChild(pp);
if (child >= 0) {
source = adapter.getChild(group, child);
} else {
source = adapter.getGroup(group);
}
}
return source;
}
代码示例来源:origin: geniusgithub/AndroidDialer
@Override
public void onCreateContextMenu(ContextMenu menu, View view,
ContextMenu.ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, view, menuInfo);
// Bail if not working with expandable long-press, or if not child
if (!(menuInfo instanceof ExpandableListContextMenuInfo)) return;
final ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuInfo;
final int groupPosition = ExpandableListView.getPackedPositionGroup(info.packedPosition);
final int childPosition = ExpandableListView.getPackedPositionChild(info.packedPosition);
// Skip long-press on expandable parents
if (childPosition == -1) return;
final AccountDisplay account = (AccountDisplay)mAdapter.getGroup(groupPosition);
final GroupDelta child = (GroupDelta)mAdapter.getChild(groupPosition, childPosition);
// Ignore when selective syncing unsupported
final int syncMode = getSyncMode(account);
if (syncMode == SYNC_MODE_UNSUPPORTED) return;
if (child != null) {
showRemoveSync(menu, account, child, syncMode);
} else {
showAddSync(menu, account, syncMode);
}
}
代码示例来源:origin: jp1017/ActivityLauncher
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
menu.add(Menu.NONE, 0, Menu.NONE, R.string.context_action_shortcut);
menu.add(Menu.NONE, 1, Menu.NONE, R.string.context_action_launch);
ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo)menuInfo;
ExpandableListView list = (ExpandableListView) getView().findViewById(R.id.expandableListView1);
switch(ExpandableListView.getPackedPositionType(info.packedPosition)) {
case ExpandableListView.PACKED_POSITION_TYPE_CHILD:
MyActivityInfo activity = (MyActivityInfo) list.getExpandableListAdapter().getChild(ExpandableListView.getPackedPositionGroup(info.packedPosition), ExpandableListView.getPackedPositionChild(info.packedPosition));
menu.setHeaderIcon(activity.icon);
menu.setHeaderTitle(activity.name);
menu.add(Menu.NONE, 2, Menu.NONE, R.string.context_action_edit);
break;
case ExpandableListView.PACKED_POSITION_TYPE_GROUP:
MyPackageInfo pack = (MyPackageInfo) list.getExpandableListAdapter().getGroup(ExpandableListView.getPackedPositionGroup(info.packedPosition));
menu.setHeaderIcon(pack.icon);
menu.setHeaderTitle(pack.name);
break;
}
super.onCreateContextMenu(menu, v, menuInfo);
}
代码示例来源:origin: PrivacyApps/document-viewer
final int type = ExpandableListView.getPackedPositionType(cmi.packedPosition);
final int groupPosition = ExpandableListView.getPackedPositionGroup(cmi.packedPosition);
final int childPosition = ExpandableListView.getPackedPositionChild(cmi.packedPosition);
内容来源于网络,如有侵权,请联系作者删除!