android中关于SimpleAdapter的问题 这里面for循环中的循环条件File file:files是什么意思
privateList<Map<String,Object>>buildListForSimpleAdapter(Stringpath){List<Map<String,...
private List<Map<String,Object>> buildListForSimpleAdapter(String path){
List<Map<String,Object>> list=new ArrayList<Map<String,Object>>();
File[] files=Utils.getPicOrder(path);
File parent=new File(path);
if(parent.getParent()!=null&&!"".equals(parent.getParent())){
fileParentPath=path;
Map<String,Object> root=new HashMap<String,Object>();
root.put("name",Contents.RETUERNPARENTDIRECTOR);
root.put("img"," ");
root.put("path",parent.getParent());
list.add(root);
}
if(files!=null&&files.length>0){
for(File file:files){
if("/".equals(file.getParent())){
fileParent.setText(R.string.sdcard_is_root_dir);
fileParent.setEnabled(false);
}else{
fileParent.setText(R.string.sdcard_parentDirector);
fileParent.setEnabled(true);
}
Map<String,Object> folder=new HashMap<String,Object>();
if(file.isDirectory()){
folder.put("img",R.drawable.folder);
folder.put("name",file.getName());
folder.put("path",file.getPath());
list.add(folder);
}else if(Utils.getFileExt(file.getPath())){
folder.put("img",R.drawable.pic);
folder.put("name",file.getName());
folder.put("path",file.getPath());
list.add(folder);
}
}
}
return list;
} 展开
List<Map<String,Object>> list=new ArrayList<Map<String,Object>>();
File[] files=Utils.getPicOrder(path);
File parent=new File(path);
if(parent.getParent()!=null&&!"".equals(parent.getParent())){
fileParentPath=path;
Map<String,Object> root=new HashMap<String,Object>();
root.put("name",Contents.RETUERNPARENTDIRECTOR);
root.put("img"," ");
root.put("path",parent.getParent());
list.add(root);
}
if(files!=null&&files.length>0){
for(File file:files){
if("/".equals(file.getParent())){
fileParent.setText(R.string.sdcard_is_root_dir);
fileParent.setEnabled(false);
}else{
fileParent.setText(R.string.sdcard_parentDirector);
fileParent.setEnabled(true);
}
Map<String,Object> folder=new HashMap<String,Object>();
if(file.isDirectory()){
folder.put("img",R.drawable.folder);
folder.put("name",file.getName());
folder.put("path",file.getPath());
list.add(folder);
}else if(Utils.getFileExt(file.getPath())){
folder.put("img",R.drawable.pic);
folder.put("name",file.getName());
folder.put("path",file.getPath());
list.add(folder);
}
}
}
return list;
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询