android.widget.ExpandableListView.isGroupExpanded()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(119)

本文整理了Java中android.widget.ExpandableListView.isGroupExpanded()方法的一些代码示例,展示了ExpandableListView.isGroupExpanded()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ExpandableListView.isGroupExpanded()方法的具体详情如下:
包路径:android.widget.ExpandableListView
类名称:ExpandableListView
方法名:isGroupExpanded

ExpandableListView.isGroupExpanded介绍

暂无

代码示例

代码示例来源:origin: androidquery/androidquery

ela.getGroupView(group, elv.isGroupExpanded(group), convertView, elv);

代码示例来源:origin: stackoverflow.com

@Override
public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition,
    long id) {
  // Implement this method to scroll to the correct position as this doesn't
  // happen automatically if we override onGroupExpand() as above
  parent.smoothScrollToPosition(groupPosition);

  // Need default behaviour here otherwise group does not get expanded/collapsed
  // on click
  if (parent.isGroupExpanded(groupPosition)) {
    parent.collapseGroup(groupPosition);
  } else {
    parent.expandGroup(groupPosition);
  }

  return true;
}

代码示例来源:origin: stackoverflow.com

myExpandableListView.setOnGroupClickListener(new OnGroupClickListener()
{
  @Override
  public boolean onGroupClick(ExpandableListView parent, 
    View v, int groupPosition, long id)
  {
    return parent.isGroupExpanded(groupPosition);
  }
});

代码示例来源:origin: stackoverflow.com

expandableList.setOnGroupClickListener(new OnGroupClickListener() {
 @Override
 public boolean onGroupClick(ExpandableListView parent, View v,
               int groupPosition, long id) { 
if(groupPosition==1)
  return true; // This way the expander cannot be collapsed
else
  return parent.isGroupExpanded(groupPosition);
   }
});

代码示例来源:origin: stackoverflow.com

expListViewObj.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
       @Override
       public boolean onGroupClick(ExpandableListView parent, View v,
                     int groupPosition, long id) {
         if(parent.isGroupExpanded(groupPosition))
         {
          // Do your Staff
         }
         else{
           // Expanded ,Do your Staff
         }
         return false;
       }
     });

代码示例来源:origin: stackoverflow.com

YOUR_EXP_LISTVIEW.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
       @Override
       public boolean onGroupClick(ExpandableListView parent, View v,
                     int groupPosition, long id) {
         if(parent.isGroupExpanded(groupPosition))
         {
          // Do your Staff
         }
         else{
           // Expanded ,Do your Staff
         }
         return false;
       }
     });

代码示例来源:origin: stackoverflow.com

mListView.setOnGroupClickListener(new OnGroupClickListener() {
  @Override
  public boolean onGroupClick(ExpandableListView parent, View clickedView, int groupPosition, long rowId) {
    ImageView groupIndicator = (ImageView) clickedView.findViewById(R.id.help_group_indicator);
    if (parent.isGroupExpanded(groupPosition)) {
      parent.collapseGroup(groupPosition);
      groupIndicator.setImageResource(R.drawable.down_icon);
    } else {
      parent.expandGroup(groupPosition);
      groupIndicator.setImageResource(R.drawable.up_icon);
     }
    return true;
  }
});

代码示例来源:origin: stackoverflow.com

mListView.setOnGroupClickListener(new OnGroupClickListener() {
   @Override
   public boolean onGroupClick(ExpandableListView parent, View clickedView, int groupPosition, long rowId) {
     ImageView groupIndicator = (ImageView) clickedView.findViewById(R.id.help_group_indicator);
     if (parent.isGroupExpanded(groupPosition)) {
       parent.collapseGroup(groupPosition);
       groupIndicator.setImageResource(R.drawable.down_icon);
     } else {
       parent.expandGroup(groupPosition);
       groupIndicator.setImageResource(R.drawable.up_icon);
      }
     return true;
   }
 });

代码示例来源:origin: gigabytedevelopers/FireFiles

private ArrayList<Long> getExpandedIds() {
  ExpandableListView list = mList;
  ExpandableListAdapter adapter = mAdapter;
  if (adapter != null) {
    int length = adapter.getGroupCount();
    ArrayList<Long> expandedIds = new ArrayList<Long>();
    for(int i=0; i < length; i++) {
      if(list.isGroupExpanded(i)) {
        expandedIds.add(adapter.getGroupId(i));
      }
    }
    return expandedIds;
  } else {
    return null;
  }
}

代码示例来源:origin: stackoverflow.com

expandableListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
   @Override
   public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
     if(parent.isGroupExpanded(groupPosition)){
       parent.collapseGroup(groupPosition);
     }else{
       boolean animateExpansion = false;
       parent.expandGroup(groupPosition,animateExpansion);
     }
     //telling the listView we have handled the group click, and don't want the default actions.
     return true;
   }
 });

代码示例来源:origin: stackoverflow.com

pointcategoryExpandableList.setOnGroupClickListener(new OnGroupClickListener(){
     @Override
     public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
               Log.d("TAG", "POSITION: "+groupPosition);
       if( parent.isGroupExpanded( groupPosition ) ){
         parent.collapseGroup( groupPosition );
       }else{
         parent.expandGroup( groupPosition );
       }
     }
   });

代码示例来源:origin: stackoverflow.com

btnIndicator.setOnClickListener(new View.OnClickListener() {
     @Override
     public void onClick(View view) {
       ExpandableListView mExpandableListView = (ExpandableListView) mParetn;
       if(mExpandableListView.isGroupExpanded(mGroupPosition)){
         mExpandableListView.collapseGroup(mGroupPosition);
       }else{
         mExpandableListView.expandGroup(mGroupPosition);
       }
     }
   });

代码示例来源:origin: stackoverflow.com

@Override
public void onBackPressed() {
  ExpandableListView elv;
  boolean groupsCollapsed = false;
  for (int i=0; i<elv.getCount(); ++i) {
    if (elv.isGroupExpanded(i)) {
      elv.collapseGroup(i);
      groupsCollapsed = true;
    }
  }

  // If no groups collapsed, call the default back button
  if (!groupsCollapsed) {
    super.onBackPressed();
  }
}

代码示例来源:origin: stackoverflow.com

public void onClick(View view)
{
  // click - do something with item       
}

public boolean onLongClick(View view)
{
  // group position was stored in view tag
  int groupPosition = (Integer) view.getTag();

  ExpandableListView listView = (ExpandableListView) findViewById(R.id.expandableListView);
  if (listView.isGroupExpanded(groupPosition))
    listView.collapseGroup(groupPosition);
  else
    listView.expandGroup(groupPosition);

  return true;
}

代码示例来源:origin: stackoverflow.com

ExpandableListView accordion = (ExpandableListView) findViewById(R.id.accordion);
accordion.setOnGroupClickListener(this);

@Override
public boolean onGroupClick(ExpandableListView paramExpandableListView, View paramView, int paramInt, long paramLong) {
  ImageView icon=(ImageView)paramView.findViewById(R.id.accordionIndicator);
  for (int i = 0; i < adapterDataCollection.size(); i++) {
    if (i == paramInt) {
      if (paramExpandableListView.isGroupExpanded(i)) {
        paramExpandableListView.collapseGroup(i);
        icon.setImageResource(R.drawable.arrow_up_np);
      } else {
        paramExpandableListView.expandGroup(i);
        icon.setImageResource(R.drawable.arrow_down_np);
      }
    } else {
      paramExpandableListView.collapseGroup(i);
      icon.setImageResource(R.drawable.arrow_up_np);
    }
  }
  paramExpandableListView.invalidate();
  return true;
}

代码示例来源:origin: stackoverflow.com

expandList.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
   @Override
   public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
     if (!parent.isGroupExpanded(groupPosition)) {
       parent.expandGroup(groupPosition);
     } else {
       parent.collapseGroup(groupPosition);
     }
     parent.setSelectedGroup(groupPosition);
     return true;
   }
 });

代码示例来源:origin: stackoverflow.com

expandList.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
   @Override
   public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
     if (!parent.isGroupExpanded(groupPosition)) {
       parent.expandGroup(groupPosition);
     } else {
       parent.collapseGroup(groupPosition);
     }
     parent.setSelectedGroup(groupPosition);
     return true;
   }
 });

代码示例来源:origin: stackoverflow.com

expListView.setOnGroupClickListener(new OnGroupClickListener() {
     @Override
     public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
       Log.d("onGroupClick:", "worked");
       parent.smoothScrollToPosition(groupPosition);
       if (parent.isGroupExpanded(groupPosition)) {
         parent.collapseGroup(groupPosition);
       } else {
         parent.expandGroup(groupPosition);
       }
       return false;
     }
   });

代码示例来源:origin: adafruit/Bluefruit_LE_Connect_Android

public void onClickInfoService(View view) {
  int groupPosition = (Integer) view.getTag();
  if (mInfoListView.isGroupExpanded(groupPosition)) {
    mInfoListView.collapseGroup(groupPosition);
  } else {
    // Expand this, Collapse the rest
    int len = mInfoListAdapter.getGroupCount();
    for (int i = 0; i < len; i++) {
      if (i != groupPosition) {
        mInfoListView.collapseGroup(i);
      }
    }
    mInfoListView.expandGroup(groupPosition, true);
  }
}

代码示例来源: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;
  }
});

相关文章

ExpandableListView类方法