所以我想出这个代码图片内容就不会出现
Map<Integer, Integer> images = new HashMap<Integer, Integer>();
images.put(1,R.drawable.a);
images.put(2,R.drawable.b);
images.put(3,R.drawable.c);
String[] abcd = {"a","b","c"};
Integer count = 3;
for(int inte = 0; inte==count;inte ++){
if(strn.get(inte).equalsIgnoreCase(abcd[inte])){
image.setImageDrawable(getResources().getDrawable(images.get(inte)));
}
}
- 把图像从可绘与整数键的HashMap
- 我提出的阵列[]与用户比较输入,for循环遍历hashmap的内容,如果条件为真,则显示图像。
这是我想要做的事情的见解,但... 现在我的问题是图像不会出现在我的代码之前。我认为我的问题有点类似于loop through hashtable或Can't See Contents,并注意到Enumeration
,Iterator
,但无法设法将它们应用到我的代码中。有人可以指导我或任何建议都可以解决我的问题。
在这个问题上接受的答案将帮助你:[从ArrayList HashMap获取多个随机值](http://stackoverflow.com/questions/14914062/get-multiple-random-values-from-arraylist-hashmap/14914068 #14914068) – jlordo 2013-02-17 16:44:43