| | |
| | | |
| | | /** |
| | | * 从TreePoint开始一直展开到顶部 |
| | | * |
| | | * @param treePoint |
| | | */ |
| | | private void openExpand(TreePoint treePoint) { |
| | |
| | | if (convertView == null) { |
| | | convertView = LayoutInflater.from(mcontext).inflate(R.layout.adapter_treeview, null); |
| | | holder = new ViewHolder(); |
| | | holder.text = (TextView) convertView.findViewById(R.id.text); |
| | | holder.icon = (ImageView) convertView.findViewById(R.id.icon); |
| | | holder.text = convertView.findViewById(R.id.text); |
| | | holder.icon = convertView.findViewById(R.id.icon); |
| | | convertView.setTag(holder); |
| | | } else { |
| | | holder = (ViewHolder) convertView.getTag(); |
| | | } |
| | | final TreePoint tempPoint = (TreePoint) getItem(position); |
| | | int level = TreeUtils.getLevel(tempPoint,pointMap); |
| | | int level = TreeUtils.getLevel(tempPoint, pointMap); |
| | | holder.icon.setPadding(25 * level, holder.icon.getPaddingTop(), 0, holder.icon.getPaddingBottom()); |
| | | if ("0".equals(tempPoint.getISLEAF())) { //如果为父节点 |
| | | if (!tempPoint.isExpand()) { //不展开显示加号 |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | public void onItemClick(int position) { |
| | | TreePoint treePoint = (TreePoint) getItem(position); |
| | | if ("1".equals(treePoint.getISLEAF())) { //点击叶子节点 |
| | |
| | | |
| | | |
| | | //选择操作 |
| | | private void onModeSelect(TreePoint treePoint){ |
| | | private void onModeSelect(TreePoint treePoint) { |
| | | if ("1".equals(treePoint.getISLEAF())) { //选择叶子节点 |
| | | //处理回填 |
| | | treePoint.setSelected(!treePoint.isSelected()); |
| | |
| | | int position = pointList.indexOf(treePoint); |
| | | boolean isSelect = treePoint.isSelected(); |
| | | treePoint.setSelected(!isSelect); |
| | | if(position == -1){ |
| | | return ; |
| | | if (position == -1) { |
| | | return; |
| | | } |
| | | if(position == pointList.size()-1){ |
| | | if (position == pointList.size() - 1) { |
| | | return; |
| | | } |
| | | position++; |
| | | for(;position < pointList.size();position++){ |
| | | TreePoint tempPoint = pointList.get(position); |
| | | if(tempPoint.getPARENTID().equals(treePoint.getPARENTID())){ //如果找到和自己同级的数据就返回 |
| | | for (; position < pointList.size(); position++) { |
| | | TreePoint tempPoint = pointList.get(position); |
| | | if (tempPoint.getPARENTID().equals(treePoint.getPARENTID())) { //如果找到和自己同级的数据就返回 |
| | | break; |
| | | } |
| | | tempPoint.setSelected(!isSelect); |