3

I am implementing a custom surface view, which is called from other activity by setContentView(new SurfaceViewClass(Context)). This class is extending the surfaceView. In the Draw() method which I have added in the surface view, I am displaying an animation that gets triggered, say, every 200 milliseconds, which means that the surfaceview thread gets triggered every 200 msecs.

My requirement is I want to add a button at the bottom of the animation that can respond to events when user has pressed it. How it is possible to do this?

Thank you!

Svante
  • 50,694
  • 11
  • 78
  • 122
jainish
  • 31
  • 1
  • 3

1 Answers1

2

The idea is to have surfaceView(i.e. your graphics) inside a FrameLayout. See the xml layout in the following link.

In the following questions, i have posted the code for the same.

Android:Crash: Binary XML file line : Error inflating class (using SurfaceView)

Let us know if it works!

Community
  • 1
  • 1
m4n07
  • 2,267
  • 12
  • 50
  • 65
  • I have done some other way rather than reading from the XML file. – jainish May 02 '11 at 14:26
  • I have created 2 buttons using the new Button inside an activity. And one surfaceView object this is a separate class and which extends the surfaceView class .So when the draw happens two buttons are drawn and the when the draw called for the Surfaceview its draw method inside the paint is getting called where I am created the Animation thread. Thank U for your response. – jainish May 02 '11 at 14:42
  • @jainish i am stuck in b/w i have to perform same task, can yu help me with the peice of yur code – Sunishtha Singh May 04 '15 at 12:02