问题描述
public List<Map<String, Object>> findMovieByRegion(String region){List<Map<String, Object>> movieList = new ArrayList<Map<String, Object>>();SQLiteDatabase db = dbHelper.getReadableDatabase();Cursor cursor = db.rawQuery("select num from Online_movie where region=?", new String[]{region});while(cursor.moveToNext()){int aa = cursor.getInt(cursor.getColumnIndex("num"));HashMap<String, Object> map = new HashMap<String, Object>();map.put("aaa", aa);System.out.println(map);movieList.add(map);}return movieList;}//______________________________________________下面是 遍历上面 数据库中的 集合MovieService ms = new MovieService(this.getBaseContext());List<Map<String,Object>> typenum = ms.findMovieByRegion("美国");for (Iterator<Map<String, Object>> typeiterator = typenum.iterator(); typeiterator.hasNext();) {Object num = typeiterator.next();//这里打印的 num 是{aaa=10},{aaa=9},{aaa=3}可是 我只想得到 10,9,3这几个数字 因为 有花括号的话 组成的路径就是错误的 Log.v("num===ggggggggggggggg>", ""+num);listmap = FileList.findFile(Environment.getExternalStorageDirectory()+"/Pictures/"+num+".jpg");}
解决方案
Object num = typeiterator.next(); 为什么用object接收,不用map呢。用map取得get(key)就可以了
解决方案二:
你遍历的是List,可List里面的元素类型是Map,当然会打印名-值对的形式,再把里面的Map遍历下吧