if statement - How can I change Image on switch case in android? -
i building android application user enter fix thing in edit text filed , value of edit text parse second activity using singleton class.
now need when text on second activity ice-cream there ice-cream image available in project need in image-view image of ice-cream display.
let take second case if user enter value food image of food should display in image-view.
i think can if..if else..else case. if right please me.
i new android.
here code -
imageview imgsport = (imageview) convertview.findviewbyid(r.id.sportimageevent); textview title = (textview) convertview.findviewbyid(r.id.title); title.settext(m.gettitle());
let me more clarify if title ice-cream set image-view ice-cream image.
try below code:
string value=m.gettitle(); if(value.equalsignorecase("icecream")){ imageview.setimageresource(r.drawable.icecream); }else if(value.equalsignorecase("food")){ imageview.setimageresource(r.drawable.food); }else if(value.equalsignorecase("desert")){ imageview.setimageresource(r.drawable.desert); }else{ //default case, if above conditions become false call }
Comments
Post a Comment