It's also possible to input text. For this, check out the TextBreakExample
in the official AndEngine examples. This example uses a standard Android TextEdit
widget to accept text, as well as the Android Text API.
It first implements a layout (res/layout/textbreakexample.xml
) that contains the following code inside a simple LinearLayout
tag:
<EditText android:id="@+id/textbreakexample_text" android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="1" android:gravity="left" android:textSize="12sp" android:singleLine="false" android:hint="@string/textbreakexample_text_default"/>
As the LinearLayout
class also has fill_parent
defined, this will create a text field, filling the available space.
In Java code, the main class is defined like this:
public class TextBreakExample extends SimpleLayoutGameActivity implements TextWatcher {
The first thing that should strike us is that we aren't using a SimpleBaseGameActivity...