0

Hello everyone I am looking for some advice, I am currently making my game and for the game menu I was thinking to do something like this menu inspiration

For the buttons like play option and stuff how do I make them clickable?

LBes
  • 3,366
  • 1
  • 32
  • 66
mrJoker
  • 53
  • 5

2 Answers2

1

If your using Buttons you should add a Listener like this:

yourButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View view) {

            //your code
        }

    });
    return true;
}

Hope that helps!

EDIT:

Found a little example here: http://examples.javacodegeeks.com/android/core/view/onclicklistener/android-onclicklistener-example/

Felix Gerber
  • 1,615
  • 3
  • 30
  • 40
  • Thanks for your reply, but how I make that section of the image clickable – mrJoker Nov 02 '15 at 10:57
  • @mrJoker you could add a transparent ui-element(like a button) over it and do it with the onClickListener. That is a little workaround I will think about another way.... – Felix Gerber Nov 02 '15 at 11:00
  • http://stackoverflow.com/questions/16670774/clickable-area-of-image is this what you need? – Felix Gerber Nov 02 '15 at 11:01
1

You may situate your button as you want, and use in your xml layout this attribute: android:visibility="invisible"

In code you set onClickListener() on this invisible button:

yourMenuButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                // your code
            }
        });
walkmn
  • 2,322
  • 22
  • 29