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 trying to add a "PlayerName" box on top of a opengl menu background, is this possible? I've tried various layouts, but they don't seem to allow an EditText box to appear on top

What is the typical way of doing something like this? Do I need to manually render the text and handle input or is there a better way? It seems like it should be possible to show the EditText on top of the GLSurfaceView somehow.

share|improve this question
    
I ended up implementing an EditBox manually to deal with text input. It wasn't too difficult although not as full featured as I'd like. –  Ash McConnell Apr 21 '11 at 13:23
add comment

1 Answer

up vote 3 down vote accepted

I found the correct way of doing this (This code is in the Activity class)

view = new MyGLSurfaceView(this, gameHandler);
editBox = new EditText(context);
editBox.setText("Hello Matron");

view.setRenderer(new OpenGLRenderer(gameHandler));
setContentView(view);

addContentView(editBox, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));

The key is using addContentView method on the Activity class to add the editBox on top of the GLSurfaceView.

Hope this helps some googlers :)

Thanks! Ash

share|improve this answer
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.