取到东西放到ArrayList里

网友投稿 633 2022-09-06

取到东西放到ArrayList>里

取到东西放到ArrayList里

public List fetch_installed_apps(){ List packages = getPackageManager().getInstalledApplications(0); list = new ArrayList>( packages.size()); Iterator l = packages.iterator(); while (l.hasNext()) { Map map = new HashMap(); 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(); map.put("name", label); map.put("desc", packageName); list.add(map); } return list; } private List> buildListForSimpleAdapter(String path) { File[] files = new File(path).listFiles(); List> list = new ArrayList>(files.length); Map root = new HashMap(); root.put("name", "/"); root.put("img", R.drawable.file_root); root.put("path", "go to root directory"); list.add(root); Map pmap = new HashMap(); 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 map = new HashMap(); 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; }

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:11个实用经典的SQL小贴士(简单的sql)
下一篇:Mac 下 TensorFlow C++ API 的编译与测试
相关文章

 发表评论

暂时没有评论,来抢沙发吧~