3

<folder
    id="-1"
    name="BaseFolder" >
    <folder
        id="1047"
        name="Folder1" >
        <folder
            id="1050"
            name="Folder1.1" />
    </folder>
    <folder
        id="1048"
        name="Folder2" >
        <folder
            id="1053"
            name="Folder2.1" />
        <folder
            id="1054"
            name="Folder2.2" />
    </folder>
    <folder
        id="1049"
        name="Folder3" >
        <folder
            id="1051"
            name="Folder3.1" />
        <folder
            id="1052"
            name="Folder3.2" />
    </folder>
</folder>

这些是我使用的类

    @Root
public class Response extends BaseResponse {

    private static final long serialVersionUID = 1L;



    @ElementList(entry="folder", inline=true)
    public ArrayList<Folder> folderList;


    public String getSuccess() {
        return success;
    }

    public void setSuccess(String success) {
        this.success = success;
    }

    @Attribute
    private String success;

    }

文件夹类

@Root
public class Folder extends BaseResponse {




    private static final long serialVersionUID = 1L;

    @Attribute
    private String id;

    @Attribute
    private String name;



    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }



}

如何访问内部文件夹标签?在我打电话的活动中

List <Folder>folders=new ArrayList<Folder>();
    Response response = new Response();
response = directoryService.getResponses();
folders=    response.folderList;

    for(int i=0;i<folders.size();i++)
            {
                Log.e("Contents of folders are ",folders.get(i).getName());

            }

我能够打印 BaseFolder。但是如何访问内部标签以及如何将它们放在列表中以便我可以在某些列表视图中显示它们。有人知道吗?

4

1 回答 1

1

我将文件夹对象更改为

@Root
public class Folder extends BaseResponse {




    private static final long serialVersionUID = 1L;

    @ElementList(entry="folder", inline=true,name="name",required=false)
    public ArrayList<Folder> llfolder;





    public ArrayList<Folder> getLlfolder() {
        return llfolder;
    }

    public void setLlfolder(ArrayList<Folder> llfolder) {
        this.llfolder = llfolder;
    }

    @Attribute(required=false)
    private String id;

    @Attribute(required=false)
    private String name;



    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }



}
于 2012-11-21T18:20:28.167 回答