Friends,
i m developing a Game.
All the drawings are handled by my sSurfaceViewClass, which is an Activity extending SurfaceView.
I overlay a few custom ui components, mainly buttons and textviews.
Everything works fine except of the overlay of the EditText.
I can not request focus for the EditText programmatically.
I want the focus on the EditText when the activty gets created. What means the keyboard pops up and the cursor is in the EditText, waiting for the input.
Heres part of my code:
addContentView(surfaceViewClass, layoutParamsCompleteLayout);
editTextKeyboard = new EditText(this);
editTextKeyboard.requestFocus();
editTextKeyboard.setAlpha(0);
editTextKeyboard.setSingleLine();
editTextKeyboard.setImeOptions(EditorInfo.IME_FLAG_NO_FULLSCREEN);
editTextKeyboard.setFocusableInTouchMode(true);
addContentView(editTextKeyboard, layoutParamsCompleteLayout);
with the method requestFocus() it works usually fine. But in this case ( surfaceView plus overlay ) it does not.
I m glad about any support. Also a workaround would help me a lot!
Thx
try using
requestFocus()after adding it to surface view.You are doing it before you add it to parent layout.