6

I am trying to create an EditText on top of an andengine game to act as an ingame chatbox. The method I am using works fine on Android 2.2.1 IDEOS 2, Emulator Android 2.1, Emulator Android 2.2, Emulator Android 2.3.

UPDATE 25/APR/2012: Recently tested on Samsung Galaxy S SGH-T959 Android 2.1-Update1, it is working fine except for minor alignment issues, is this a problem of Android 2.3 on Samsung.

The following devices do not display the EditText control on top of the andengine game activity:

  1. Samsung Y S5360 Android 2.3.6
  2. Samsung Galaxy 551 Android 2.3.6

This is what I am doing in Game Activity

chatEditText = new EditText(this);
chatEditText.setSingleLine(true);
chatEditText.setId(1);
chatEditText.setHint(" ");

tableLayout = new TableLayout(this);
tableLayout.setVerticalGravity(Gravity.BOTTOM);

tableLayout.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));

tableLayout.setHorizontalGravity(Gravity.CENTER_HORIZONTAL);
tableLayout.setPadding(25, 25, 25, 308);
tableLayout.addView(chatEditText);
LayoutParams lp = new ViewGroup.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);

this.addContentView(tableLayout, lp);
tableLayout.setVisibility(View.GONE);

To show/ hide the control I am setting its visibility to View.VISIBLE or View.GONE as required using a Handler.

The above works on an IDEOS 2 Android 2.2.1 and emulators but not on Samsung Galaxy 551, Samsung Galaxy S 5360, other devices needs to be tested. Please help.

The above method was described here: AndEngine forum, display UI in andengine Another method was suggested, where a Popup dialog box will display the EditText here AndEngine helper class Input Text, but that is not suitable for my usecase.

Would like to use standard EditText, else the only way out looks like implementing own fake keyboard and fake input sprite in AndEngine, with limitation that Hardware and International keyboards may not be available. Any help will be appreciated.

APZ
  • 176
  • 8

0 Answers0