Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am newbie Android developer, and I am starting out with a simple Sudoku game. The problem I am facing right now is that I have my game showing on a dedicated Activity, which is displaying a custom View class. I have the code within the onDraw function. Now I want to show a custom keypad view, which is a separate class extending View, whenever a user clicks on a block in the Sudoku grid.

I am extremely confused as to how I should go about doing this. I am reluctant to create a dedicated activity for just this keypad, and want to show this keypad over the Sudoku grid view that the activity is currently displaying.

The activity is using setContentView(myCustomGridViewClass) to show the grid. Now I want something to the equivalent of

onTouch -> setContentView(myCustomKeypadView), though this should appear over the previous view.

I have tried reading about the LayoutInflater, but did not understand how to use it to show the keypad within this same activity. This is probably a very noob question, but any help, including any other questions, or sources I could refer to for an answer would be highly appreciated.

Regards,

share|improve this question
add comment

1 Answer 1

up vote 3 down vote accepted

You could place both views in a FrameLayout or a RelativeLayout and control the keypad's visibility (http://developer.android.com/reference/android/view/View.html#setVisibility(int)) when needed.

Change setContentView(myCustomGridViewClass) to setContentView(R.layout.id_of_my_layout), then write id_of_my_layout.xml that contains the layout (more help here http://developer.android.com/guide/topics/ui/declaring-layout.html).

Make sure to add your keypad view after the game view in your layout xml, otherwise the game view will be placed on top of it and you'll never see the keypad :)

share|improve this answer
    
Thanks for the response. I am working on this solution, and I think I should be able to make this work. Marking this as the answer, coz I can see how this will work. Thanks again. –  monologish Apr 15 '13 at 10:58
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.