android - making buttons appear and disappear on an image view -


I have an image view, I want to create two buttons that enable users to move to the next or previous image When a user taps the image, the button should be visible and on the second tap, the button should be missing. How to go about doing this?

Fortunately, I am currently working on one thing and this is my code

xml code

  & lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; ; & Lt; RelativeLayout xmlns: Android = "http://schemas.android.com/apk/res/android" Android: layout_width = "fill_parent" android: layout_height = "fill_parent" & gt; & Lt; ImageView Android: id = "@ + id / image" Android: layout_width = "fill_parent" Android: layout_height = "fill_parent" /> & Lt; LinearLayout android: id gone = "@ + id / button_holder" Android: Layout_width = "Fill_parent" Android: Layout_height = "Wrap_content" android: orientation = "horizontal" android: layout_alignParentBottom = "true" Android: visibility = "" & gt ; Android: Android: layout_height = "wrap_content" android: layout_weight = "1" /> Android: Android: & lt; Button Android: id = "@ + id / not yet" Android: Text = "Cancel" Android: layout_width = "fill_parent" android: layout_height = "wrap_content" android: layout_weight = "1" /> & Lt; / LinearLayout & gt; & Lt; / RelativeLayout & gt;   

Main code

  button mBuy = (button) findViewById (R.id.buy); MBuy.setOnClickListener (New OnClickListener () {@Override Click Public Zero (see V) {}}); Button mCancel = (button) findViewById (R.id.cancel); MCancel.setOnClickListener (New OnClickListener () {@Override Click Public Zero (see V) {Finish ();}}); Image view mView = (ImageView) findViewById (R.id.image); mView.setOnClickListener (New OnClickListener () {See @Override public void onClick (v) {LinearLayout mLayout = (LinearLayout) findViewById (R.id.button_holder); if (isVisible) {isVisible = true! mLayout.setVisibility (see. Visual );} And (visual = falls; mlayout .setwasibility (see genes);}}});    

Comments