com.zx.zxutils.views.ExpandableView.ZXExpandBean类的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(5.4k)|赞(0)|评价(0)|浏览(94)

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

ZXExpandBean介绍

暂无

代码示例

代码示例来源:origin: StannyBing/ZXUtils

private void setShowById(List<ZXExpandBean> dataList, String id) {
  for (int i = 0; i < dataList.size(); i++) {
    if (id.equals(dataList.get(i).getId())) {
      dataList.get(i).setShowChild(!dataList.get(i).isShowChild());
      //如果关闭item,就关闭它的所有子集
      if (!dataList.get(i).isShowChild()) {
        closeChild(dataList.get(i));
      }
      return;
    }
    if (dataList.get(i).getChildList() != null && dataList.get(i).getChildList().size() > 0) {
      setShowById(dataList.get(i).getChildList(), id);
    }
  }
}

代码示例来源:origin: StannyBing/ZXUtils

public ZXExpandBean(Object customData, String itemText) {
  setCustomData(customData);
  setItemText(itemText);
}

代码示例来源:origin: StannyBing/ZXUtils

private void setIndex(List<ZXExpandBean> dataList, int index) {
  for (int i = 0; i < dataList.size(); i++) {
    dataList.get(i).setIndex(index);
    String uuid = UUID.randomUUID().toString();
    dataList.get(i).setId(uuid);
    dataList.get(i).setShowChild(false);
    if (dataList.get(i).getChildList() != null && dataList.get(i).getChildList().size() > 0) {
      int item = index + 1;
      setIndex(dataList.get(i).getChildList(), item);
    }
  }
}

代码示例来源:origin: StannyBing/ZXUtils

private void closeChild(ZXExpandBean zxExpandBean) {
  if (zxExpandBean.getChildList() == null) {
    return;
  }
  for (int i = 0; i < zxExpandBean.getChildList().size(); i++) {
    zxExpandBean.getChildList().get(i).setShowChild(false);
    if (zxExpandBean.getChildList().get(i).getChildList() != null && zxExpandBean.getChildList().get(i).getChildList().size() > 0) {
      closeChild(zxExpandBean.getChildList().get(i));
    }
  }
}

代码示例来源:origin: StannyBing/ZXUtils

@Override
  public void onSelectClick(int position) {
    try {
      String id = showList.get(position).getId();
      if (id != null && id.length() > 0) {
        if (!isMultiSelected) {
          setSelect(dataList,false);
        } else {
          if (showList.get(position).getChildList() != null && showList.get(position).getChildList().size() > 0) {
            setSelect(showList.get(position).getChildList(), !showList.get(position).isSelected());
          }
        }
        showList.get(position).setSelected(!showList.get(position).isSelected());
        showList.clear();
        refresh(dataList);
        adapter.notifyDataSetChanged();
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
};

代码示例来源:origin: StannyBing/ZXUtils

MyHolder myHolder = (MyHolder) holder;
ZXExpandBean expandBean = showList.get(position);
myHolder.tvInfo.setText(expandBean.getItemText());
ViewGroup.LayoutParams params = myHolder.viewIndex.getLayoutParams();
params.width = ZXSystemUtil.dp2px(30 * expandBean.getIndex());
myHolder.viewIndex.setLayoutParams(params);
if (expandBean.getChildList() == null) {
  myHolder.ivArrow.setVisibility(View.INVISIBLE);
} else if (expandBean.isShowChild()) {
  myHolder.ivArrow.setVisibility(View.VISIBLE);
  myHolder.ivArrow.setBackground(ContextCompat.getDrawable(context, R.mipmap.arrow_open));
myHolder.tvInfo.setTextSize(textSizeSp);
if (showSelect) {
  if (expandBean.isSelected()) {
    myHolder.ivSelect.setVisibility(View.VISIBLE);
    myHolder.ivSelect.setBackground(ContextCompat.getDrawable(context, R.mipmap.select));
    myHolder.ivSelect.setBackground(ContextCompat.getDrawable(context, R.mipmap.not_select));
  if (expandBean.getChildList() != null && !menuCanSelect) {
    myHolder.ivSelect.setVisibility(View.INVISIBLE);
  } else {

代码示例来源:origin: StannyBing/ZXUtils

private void setSelect(List<ZXExpandBean> dataList, boolean select) {
  for (int i = 0; i < dataList.size(); i++) {
    dataList.get(i).setSelected(select);
    if (dataList.get(i).getChildList() != null && dataList.get(i).getChildList().size() > 0 && dataList.get(i).isShowChild()) {
      setSelect(dataList.get(i).getChildList(),select);
    }
  }
}

代码示例来源:origin: StannyBing/ZXUtils

@Override
public void onOpenClick(int position) {
  try {
    String id = showList.get(position).getId();
    if (id != null && id.length() > 0) {
      setShowById(dataList, id);
      showList.clear();
      refresh(dataList);
      adapter.notifyDataSetChanged();
    }
  } catch (Exception e) {
    e.printStackTrace();
  }
}

代码示例来源:origin: StannyBing/ZXUtils

private void refresh(List<ZXExpandBean> dataList) {
  for (int i = 0; i < dataList.size(); i++) {
    showList.add(dataList.get(i));
    if (dataList.get(i).getChildList() != null && dataList.get(i).getChildList().size() > 0 && dataList.get(i).isShowChild()) {
      refresh(dataList.get(i).getChildList());
    }
  }
}

代码示例来源:origin: StannyBing/ZXUtils

setContentView(R.layout.activity_expand_view);
for (int i = 0; i < 5; i++) {
  ZXExpandBean expandBean1 = new ZXExpandBean("123000", "123");
  List<ZXExpandBean> dataList1 = new ArrayList<>();
  for (int j = 0; j < 3; j++) {
    ZXExpandBean expandBean2 = new ZXExpandBean("120003", "123");
    List<ZXExpandBean> dataList2 = new ArrayList<>();
    for (int k = 0; k < 3; k++) {
      dataList2.add(new ZXExpandBean("12003", "123"));
    expandBean2.setChildList(dataList2);
    dataList1.add(expandBean2);
  expandBean1.setChildList(dataList1);
  dataList.add(expandBean1);

代码示例来源:origin: StannyBing/ZXUtils

@Override
  public void onItemClick(ZXExpandBean expandBean, int showPosition) {
    ZXToastUtil.showToast(expandBean.getId());
    recyclerHelper.changeOpenStatus(showPosition);
  }
})

代码示例来源:origin: StannyBing/ZXUtils

@Override
public void onTextClick(int position) {
  try {
    String id = showList.get(position).getId();
    if (id != null && id.length() > 0) {
      if (itemClickListener != null) {
        itemClickListener.onItemClick(showList.get(position), position);//数据点击事件
      } else {
        onOpenClick(position);
      }
      adapter.notifyDataSetChanged();
    }
  } catch (Exception e) {
    e.printStackTrace();
  }
}

相关文章