android - how to dynamically add image to imageView -


i wondering if of know how this. have activity has key value pair , trying display image if key equal string else don't show image.

does know how or start trying work right?

 final string spliteddouble[] = companystring.split(",,");      string[] arrayofstring = { "beard vape co;beard_vape_co", "two;zwei", "three;drei" };      hashtable<string, string> hashtable = new hashtable<string, string>();     for(string s: arrayofstring){         string[] array = s.split(";");         string skey ="", svalue="";         if(array.length > 1){             skey = array[0]; svalue = array[1];             hashtable.put(skey, svalue);             if(skey.tostring().equals(liquidcompany)){                 imageview.setimageresource(integer.parseint("r.drawable." + svalue.tostring()));             }         } 

this have loop

if have layout imageview set, can use view.setvisibility show or hide imageview:

imageview image = findviewbyid(r.id.image); if (key.equals("string"))         image.setvisibility(view.visible); else     image.setvisibility(view.gone); 

if want change image after you've inflated layout, can use

image.setimageresource(r.drawable.whatever); 

Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -