CCTextFieldTTF won't work on Android on Lua project

CCTextFieldTTF won't work on Android on Lua project
0.0 0


I went through a lot of investigation:

Now I got to a part where don’t know where to go further.

It seems that due to a different way Activity is created on normal cocos2dx android projects then in Lua android projects I cannot use the text field.
I’ve tried changing my activity to set the mTextField variable, but when I try to get it’s null, where in normal android project [I used android tests project] it is a reference to a widget.

Any tips on how to proceed with this?


CCTextFieldTTF issue - keyboard not shown

Finally got it

What I did was:

  • Create class org.cocos2dx.lib.LuaGLSurfaceView
    package org.cocos2dx.lib;

import android.content.Context;
import android.util.AttributeSet;
import android.view.KeyEvent;

public class LuaGLSurfaceView extends Cocos2dxGLSurfaceView {

public LuaGLSurfaceView(Context context, AttributeSet set) {
super(context, set);

public LuaGLSurfaceView(Context context) {

public boolean onKeyDown(int keyCode, KeyEvent event) {
// exit program when key back is entered
if (keyCode == KeyEvent.KEYCODE_BACK) {
return super.onKeyDown(keyCode, event);

- Remove inner class `LuaGLSurfaceView` from the activity generated for your app - Modify `res/layout/game_demo.xml` : change `org.cocos2dx.lib.Cocos2dxGLSurfaceView` to `org.cocos2dx.lib.LuaGLSurfaceView` - Modify code in your activity from:
mGLView = new LuaGLSurfaceView(this);


        mGLView = (LuaGLSurfaceView) findViewById(;

and also change declaration:

private GLSurfaceView mGLView;


private Cocos2dxGLSurfaceView mGLView;

Now rebuild your project and you are ready to go :slight_smile: