本文整理了Java中android.widget.ExpandableListAdapter
类的一些代码示例,展示了ExpandableListAdapter
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ExpandableListAdapter
类的具体详情如下:
包路径:android.widget.ExpandableListAdapter
类名称:ExpandableListAdapter
暂无
代码示例来源:origin: androidquery/androidquery
public T expand(boolean expand){
if(view instanceof ExpandableListView){
ExpandableListView elv = (ExpandableListView) view;
ExpandableListAdapter ela = elv.getExpandableListAdapter();
if(ela != null){
int count = ela.getGroupCount();
for(int i = 0; i < count; i++){
if(expand){
elv.expandGroup(i);
}else{
elv.collapseGroup(i);
}
}
}
}
return self();
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public boolean onChildClick(ExpandableListView parent, View v,
int groupPosition, int childPosition,
long id) {
Toast.makeText(this,
adapter.getChild(groupPosition, childPosition)
.toString(), Toast.LENGTH_SHORT).show();
return(false);
}
代码示例来源:origin: androidquery/androidquery
ela.getGroupView(group, elv.isGroupExpanded(group), convertView, elv);
ela.getChildView(group, child, child == ela.getChildrenCount(group) - 1, convertView, elv);
代码示例来源:origin: stackoverflow.com
private void setExpandableListViewHeightBasedOnChildren(ExpandableListView expandableListView, Integer expandedGroupPosition) {
ExpandableListAdapter expandableListAdapter = expandableListView.getExpandableListAdapter();
if (expandableListAdapter == null) {
return;
}
int totalHeight = 0;
int totalDividerHeight = 0;
for (int i = 0; i < expandableListAdapter.getGroupCount(); i++) {
View groupItem = expandableListAdapter.getGroupView(i, expandedGroupPosition != null, null, expandableListView);
totalHeight += Utils.convertDpToPixel(92.42f, this);
if(expandedGroupPosition != null && expandedGroupPosition.equals(i)) {
for(int j=0;j<expandableListAdapter.getChildrenCount(i);j++) {
View childItem = expandableListAdapter.getChildView(i, j, j+1==expandableListAdapter.getChildrenCount(i), null, expandableListView);
totalHeight += Utils.convertDpToPixel(92.42f, this);
}
totalDividerHeight += expandableListView.getDividerHeight() * (expandableListAdapter.getChildrenCount(i)-1);
}
}
totalDividerHeight += expandableListView.getDividerHeight() * (expandableListAdapter.getGroupCount()-1);
ViewGroup.LayoutParams params = expandableListView.getLayoutParams();
params.height = totalHeight + totalDividerHeight;
expandableListView.setLayoutParams(params);
expandableListView.requestLayout();
}
代码示例来源:origin: stackoverflow.com
public void onClick(View v) {
System.out.println("Save clicked");
for(int i = 0; i < listAdapter.getGroupCount();i++) {
for (int k = 0; k < listAdapter.getChildrenCount(i); k++) {
CustomChilds child = listAdapter.getChild(i, k);
String unit=child.getUnit();
String note=child.getNote();
代码示例来源:origin: xiangzhihong/gpuImage
public Object getItem( int flatListPos ) {
final PositionMetadata posMetadata = getUnflattenedPos( flatListPos );
Object retValue;
if( posMetadata.position.type == ExpandableHListPosition.GROUP ) {
retValue = mExpandableListAdapter.getGroup( posMetadata.position.groupPos );
}
else if( posMetadata.position.type == ExpandableHListPosition.CHILD ) {
retValue = mExpandableListAdapter.getChild( posMetadata.position.groupPos, posMetadata.position.childPos );
}
else {
// TODO: clean exit
throw new RuntimeException( "Flat list position is of unknown type" );
}
posMetadata.recycle();
return retValue;
}
代码示例来源:origin: gigabytedevelopers/FireFiles
private void restoreExpandedState(ArrayList<Long> expandedIds) {
this.expandedIds = expandedIds;
if (expandedIds != null) {
ExpandableListView list = mList;
ExpandableListAdapter adapter = mAdapter;
if (adapter != null) {
for (int i=0; i<adapter.getGroupCount(); i++) {
long id = adapter.getGroupId(i);
if (expandedIds.contains(id)) list.expandGroup(i);
}
}
}
}
代码示例来源:origin: stackoverflow.com
/**
* Adds new items when adapter is modified
*/
public void resetItems() {
ExpandableListAdapter adp=swipeListView.getExpandableListAdapter();
if (adp != null) {
int count = 0;
for (int i=0; i<adp.getGroupCount();i++){
//Add the total children and the group itself.
count+=adp.getChildrenCount(i) + 1;
}
for (int i = opened.size(); i <= count; i++) {
opened.add(false);
openedRight.add(false);
checked.add(false);
}
}
}
代码示例来源:origin: mttkay/calculon
public MultiViewAssertion groups() {
ExpandableListAdapter adapter = getAdapter();
int count = adapter.getGroupCount();
List<View> views = new ArrayList<View>(count);
for (int i = 0; i < count; i++) {
views.add(adapter.getGroupView(i, false, null, listView));
}
return new MultiViewAssertion(testCase, activity, views);
}
代码示例来源:origin: stackoverflow.com
mDrawerLayout = (DrawerLayout)findViewById(R.id.drawer_layout);
prepareListData();
listAdapter = new ExpandableListAdapter(
ExpandablelistViewActivity.this, listDataHeader, listDataChild);
int count = listAdapter.getGroupCount();
for (int i = 0; i < count; i++) {
expListView.expandGroup(i);
代码示例来源:origin: mttkay/calculon
public MultiViewAssertion children(int groupPosition) {
ExpandableListAdapter adapter = getAdapter();
int count = adapter.getChildrenCount(groupPosition);
List<View> views = new ArrayList<View>(count);
boolean lastChild;
for (int i = 0; i < count; i++) {
lastChild = isLastChild(groupPosition, i);
views.add(adapter.getChildView(groupPosition, i, lastChild, null, listView));
}
return new MultiViewAssertion(testCase, activity, views);
}
代码示例来源:origin: mttkay/calculon
private boolean isLastChild(int groupPosition, int childPosition) {
return (childPosition == getAdapter().getChildrenCount(groupPosition) - 1);
}
代码示例来源:origin: xiangzhihong/gpuImage
public View getView( int flatListPos, View convertView, ViewGroup parent ) {
final PositionMetadata posMetadata = getUnflattenedPos( flatListPos );
View retValue;
if( posMetadata.position.type == ExpandableHListPosition.GROUP ) {
retValue = mExpandableListAdapter.getGroupView( posMetadata.position.groupPos, posMetadata.isExpanded(), convertView, parent );
}
else if( posMetadata.position.type == ExpandableHListPosition.CHILD ) {
final boolean isLastChild = posMetadata.groupMetadata.lastChildFlPos == flatListPos;
retValue = mExpandableListAdapter.getChildView( posMetadata.position.groupPos, posMetadata.position.childPos, isLastChild, convertView, parent );
}
else {
// TODO: clean exit
throw new RuntimeException( "Flat list position is of unknown type" );
}
posMetadata.recycle();
return retValue;
}
代码示例来源:origin: xiangzhihong/gpuImage
public long getItemId( int flatListPos ) {
final PositionMetadata posMetadata = getUnflattenedPos( flatListPos );
final long groupId = mExpandableListAdapter.getGroupId( posMetadata.position.groupPos );
long retValue;
if( posMetadata.position.type == ExpandableHListPosition.GROUP ) {
retValue = mExpandableListAdapter.getCombinedGroupId( groupId );
}
else if( posMetadata.position.type == ExpandableHListPosition.CHILD ) {
final long childId = mExpandableListAdapter.getChildId( posMetadata.position.groupPos, posMetadata.position.childPos );
retValue = mExpandableListAdapter.getCombinedChildId( groupId, childId );
}
else {
// TODO: clean exit
throw new RuntimeException( "Flat list position is of unknown type" );
}
posMetadata.recycle();
return retValue;
}
代码示例来源:origin: stackoverflow.com
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id)
{
ExpandableListAdapter itemAdapter = parent.getExpandableListAdapter();
String selectedItem = (String)itemAdapter.getChild(groupPosition, childPosition);
groupHeader(selectedItem);
if(parent.isGroupExpanded(groupPosition))
{
parent.collapseGroup(groupPosition);
}
// your logic here
// expandableListArrayList.add() or expandableListArrayList.remove()
// or whatever
itemAdapter.notifyDataSetChanged();
return true;
}
});
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public void onGroupExpand(int groupPosition) {
Toast.makeText(this,
"Expanding: "
+ adapter.getGroup(groupPosition).toString(),
Toast.LENGTH_SHORT).show();
}
代码示例来源:origin: xiangzhihong/gpuImage
/**
* Gets the ID of the group or child at the given <code>position</code>.
* This is useful since there is no ListAdapter ID -> ExpandableListAdapter
* ID conversion mechanism (in some cases, it isn't possible).
*
* @param position The position of the child or group whose ID should be
* returned.
*/
private long getChildOrGroupId( ExpandableHListPosition position ) {
if( position.type == ExpandableHListPosition.CHILD ) {
return mAdapter.getChildId( position.groupPos, position.childPos );
}
else {
return mAdapter.getGroupId( position.groupPos );
}
}
代码示例来源:origin: stackoverflow.com
adapter = new ExpandableListAdapter() {
int groupPosition, int childPosition, long id) {
Object x =adapter.getChild(groupPosition, childPosition);
代码示例来源:origin: mttkay/calculon
private View getGroupView(int groupPosition) {
return getAdapter().getGroupView(groupPosition, false, null, listView);
}
代码示例来源:origin: mttkay/calculon
private View getChildView(int groupPosition, int childPosition, boolean lastChild) {
return getAdapter().getChildView(groupPosition, childPosition, lastChild, null, listView);
}
内容来源于网络,如有侵权,请联系作者删除!