ImageButton Click Action Android -


I have stored image button information in an XML, this image is path, width, height and so on but since many images , I want to store the data of each image button, while it has been clicked. For example, if there are two buttons named Men and Women, then I want to set the string value = "male"; If the male image button is clicked but it did not work. Can anyone help me?

  Public Zero AddAllImageButtons () throws IOException {AbsolutLayout Layout = (AbsoluteLayout) findViewById (R.id.layout1); ImageButton BTN = new image button (this); Layout.addView (btn); Absolute layout Layout After Hours = (Full Layout Outline) BTN GallawayParam (); AbsParams.x = x; absParams.y = y; btn.setLayoutParams (absParams); Btn.setBackgroundDrawable (zero); btn.setImageBitmap (BitmapFactory.decodeStream (getAssets () open (path)).); If (element.edu ("imagebutton" );}}); }   

The ID is the Image Button ID that is created in the xml file. The Alertbox text for this example does not show "female".

  You can set the tag ("value") to set the value in ImageButton BTN On and on the onclick event, you can use the GetTag () function to retrieve the value and set it to gender. Use Btn.setTag (elementid); Whenever you add a BTN to the layout ....... BTN.SetOnClicklist you V.GetTag () ToString () can get values ​​and set it for gender ...... btn.setOnClickListener (see new OnClickListener () {public void onClick (see v) {gender = V.gettag () .toString (); Generated Alertbox (gender);}});    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -