Thursday, 15 April 2010

java - how to display an image without resource image yet -



java - how to display an image without resource image yet -

i have created imageview in layout, it's id "j", yet doesn't have image display. in same layout there edittext , button, 1 time there written on edittext , user press button want condition(if , else) check text/string edittext has , if equal to, lets "a", display image using imageview of j(which initialized), don't know how to.

public void abc(view view){//what happens when button clicked; edittext = (edittext) findviewbyid(r.id.a); string aa = a.gettext().tostring().touppercase();//alternative string imageview j=(imageview)findviewbyid(r.id.j); if (aa.equals("a"){ //problem:here code displays image using 'j', don't know how. }else{ } }

first alter edittext string uppercase because comparing "a"

string aa = a.gettext().tostring().touppercase();//alternative string

and display image

if (aa.equals("a"){ j.setimageresource(r.drawable.my_image); }else{ }

where my_image.png in project's drawable folder.

java android string image

No comments:

Post a Comment