android - How to create button in my own View -


i'm creating simple game learn game development's basics on android.

there

class gameview extends view 

i'm extend view (should extend view? or viewgroup? or other? - there basicly bitmaps in game , may custom wigets)

there sprites in view , want create custom "strike" button using imagebutton (should use imagebutton wiget?)

how can add wiget without using xml layout(!)

//for example simple button class gameview extends view {     private button btn;       public gamemainview(context context)     {         super(context);         btn = new button(context);           } } 

how display button in game?

you should extend viewgroup: when override ondraw canvas. you'll have manually set position of button view if call draw method canvas should display fine.

edit: http://developer.android.com/guide/topics/ui/custom-components.html has info need. @ compound controls section.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -