Is it possible to add a button to a class that extends View? “”public class josh extends View “” If not how can I merge a button onto the view when it is referenced in my main activity? uhg please help….
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Two ways:
Have both the button and your custom view as children of a FrameLayout, by which the button can be drawn over your custom view.
Don’t have a real button. Instead, draw something that looks like a button, treat touch events specially if they’re within its dimensions, etc. This is more appropriate for something like a game.
I believe you can do #2 but have a subclass of Button do the drawing, so that it performs exactly like a normal button and is just positioned/sized by your custom view, but I don’t know how to do this.