2010-03-29 100 views
0

我需要一种很好的方法来维护多个表单层次数据以供选择菜单。 因此,例如,如果我有 A和B,每一个可能有1 2 3 所以 一个 A1 A2 A3 乙 B1 B2 B3在J2ME中维护多层次选择菜单列表的好方法

这能持续多久,让我可以有A - > A1 - > A1.1 - > A1.1.1 -.... 我有以下班级,工作正常但我怀疑我们可以做得更好。

我只需要一个妮选择树比如Widget进行选择,但选择的每一层楼,在另一种形式(J2ME)

import java.util.Vector; 
public class Tag { 
    private String tag; 
    private Vector childTags; 
    private Tag parent; 

    Tag(String tag, Vector childtag) 
    { 
     this.tag = tag; 
     this.childTags= childTags; 
    } 

    public void setChildTags(Vector childTags) { 
     this.childTags = childTags; 
    } 

    public Vector getChildTags() { 
     return this.childTags; 
    } 

    public String getTag() { 
     return this.tag; 
    } 


    public String toString(int depth) 
    { 
       String a =""; 
     if(depth==0) 
     { 
      a = a + this.getTag(); 
     } 

     if(this.getChildTags()!= null) 
     { 

        for(int k=0;k <this.getChildTags().capacity(); k++) 
         { 
           for (int i=0; i<depth; i++) { 
             a = a + ("-"); 
           } 
           a = a+ (((Tag)this.getChildTags().elementAt(k)).toString(depth++)); 
     } } 
    return a; 
     } 


} 
+0

而你的问题是......究竟是什么? – 2010-03-30 11:41:14

回答