/**
   * 相应ListView的点击事件 展开或关闭某节点
   *
   * @param position
   */
  public void expandOrCollapse(int position) {
    KLNode n = mNodes.get(position);

    if (n != null) // 排除传入参数错误异常
    {
      if (!n.isLeaf()) {
        n.setExpand(!n.isExpand());
        mNodes = KLTreeHelper.filterVisibleNode(mAllNodes);
        notifyDataSetChanged(); // 刷新视图
      }
    }
  }
  /**
   * @param mTree
   * @param context
   * @param datas
   * @param defaultExpandLevel 默认展开几级树
   * @throws IllegalArgumentException
   * @throws IllegalAccessException
   */
  public KLTreeListViewAdapter(
      ListView mTree, Context context, List<T> datas, int defaultExpandLevel)
      throws IllegalArgumentException, IllegalAccessException {
    mContext = context;
    /** 对所有的Node进行排序 */
    mAllNodes = KLTreeHelper.getSortedNodes(datas, defaultExpandLevel);
    /** 过滤出可见的Node */
    mNodes = KLTreeHelper.filterVisibleNode(mAllNodes);
    mInflater = LayoutInflater.from(context);

    /** 设置节点点击时,可以展开以及关闭;并且将ItemClick事件继续往外公布 */
    mTree.setOnItemClickListener(
        new OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            expandOrCollapse(position);

            if (onTreeNodeClickListener != null) {
              onTreeNodeClickListener.onClick(mNodes.get(position), position);
            }
          }
        });
  }