取到东西放到ArrayList<Map<String, Object;;里
Posted TechOnly
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了取到东西放到ArrayList<Map<String, Object;;里相关的知识,希望对你有一定的参考价值。
public List fetch_installed_apps()
List<ApplicationInfo> packages = getPackageManager().getInstalledApplications(0);
list = new ArrayList<Map<String, Object>>(
packages.size());
Iterator<ApplicationInfo> l = packages.iterator();
while (l.hasNext())
Map<String, Object> map = new HashMap<String, Object>();
ApplicationInfo app = (ApplicationInfo) l.next();
String packageName = app.packageName;
String label = "";
try
label = getPackageManager().getApplicationLabel(app).toString();
catch (Exception e)
Log.i("Exception",e.toString());
map = new HashMap<String, Object>();
map.put("name", label);
map.put("desc", packageName);
list.add(map);
return list;
private List<Map<String, Object>> buildListForSimpleAdapter(String path)
File[] files = new File(path).listFiles();
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>(files.length);
Map<String, Object> root = new HashMap<String, Object>();
root.put("name", "/");
root.put("img", R.drawable.file_root);
root.put("path", "go to root directory");
list.add(root);
Map<String, Object> pmap = new HashMap<String, Object>();
pmap.put("name", "..");
pmap.put("img", R.drawable.file_parent);
pmap.put("path", "go to paranet Directory");
list.add(pmap);
for (File file : files)
Map<String, Object> map = new HashMap<String, Object>();
if(file.isDirectory())
map.put("img", R.drawable.directory);
else
map.put("img", R.drawable.file_doc);
map.put("name", file.getName());
map.put("path", file.getPath());
list.add(map);
return list;
以上是关于取到东西放到ArrayList<Map<String, Object;;里的主要内容,如果未能解决你的问题,请参考以下文章
java Map<String,ArrayList<String>> 如何转化为Map<String,List<String>>?
求教arraylist里面放map,怎么循环遍历得到map里面的数据,如:List<Map<String, String>> list = new Ar
List<Map> Productlist = new ArrayList<Map>(); 帮忙举例解释一下这是啥意思。