<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.But如何访问内部标签以及如何在列表中获取它们以便我可以在某个列表视图中显示它们。任何人都有任何想法吗?
答案 0 :(得分:1)
我将Folder对象更改为
@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;
}
}