java - Image content of HashMap won't appear -
so come code
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))); } }
to set images drawables hashmap integer keys i made array[] compare user input,a loop traverse content of hashmap , to display image if status true. this insight of want done but... problem image wont appear prior code. think question bit similar loop through hashtable, or can't see contents , notice enumeration
, iterator
can't manage apply them in code. can guide me or suggestion fine solve problem.
adapted reply here:
change
for(int inte = 0; inte==count; inte++){ // start inte beeing 0, execute while inte 3 (count 3) // never true
to
for(int inte = 0; inte < count; inte++){ // start inte beeing 0, execute while inte smaller 3 // true 3 times
explanation:
a loop has next structure:
for (initialization; condition; update)
initialization
executed 1 time before loop starts. condition
checked before each iteration of loop , update
executed after every iteration.
your initialization
int inte = 0;
(executed once). condition
inte == count
, false, because inte
0
, count
3
. status false
, , loop skipped.
java android
No comments:
Post a Comment