android - How to resize an ImageView by pressing a MenuItem -


i trying create imageview resized when user presses menuitem. tried use following code, error , application stops.

@override public boolean onoptionsitemselected(menuitem item) {     switch(item.getitemid())     {         case r.id.sub_item_25_percent:             try             {             layoutparams params = new layoutparams(imageview1.getlayoutparams());             params.width = pages.page_width_25_percent;             params.height = pages.page_height_25_percent;              imageview1.setlayoutparams(params);             }             catch(exception ex)             {                 toast.maketext(this, ex.getmessage(), toast.length_short);             }             break;      }        

}

as can see, used try-catch-block informations exception, application still stopping without displaying toast.

does have clue fix problem?

try this:

@override public boolean onoptionsitemselected(menuitem item)   {     switch(item.getitemid())     {         case r.id.sub_item_25_percent:              imageview1.getlayoutparams().width = pages.page_width_25_percent;             imageview1.getlayoutparams().height = pages.page_height_25_percent;              imageview1.requestlayout();          break;      }        

}


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -