protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    String packageName = getApplication().getPackageName();
    super.setPackageName(packageName);

    setContentView(R.layout.activity_main);
    mGLView = (Cocos2dxGLSurfaceView) findViewById(R.id.game_gl_surfaceview);
    mGLView.setTextField((EditText) findViewById(R.id.textField));
  }
Exemple #2
0
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (detectOpenGLES20()) {
      // get the packageName,it's used to set the resource path
      String packageName = getApplication().getPackageName();
      super.setPackageName(packageName);

      // FrameLayout
      ViewGroup.LayoutParams framelayout_params =
          new ViewGroup.LayoutParams(
              ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT);
      FrameLayout framelayout = new FrameLayout(this);
      framelayout.setLayoutParams(framelayout_params);

      // Cocos2dxEditText layout
      ViewGroup.LayoutParams edittext_layout_params =
          new ViewGroup.LayoutParams(
              ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
      Cocos2dxEditText edittext = new Cocos2dxEditText(this);
      edittext.setLayoutParams(edittext_layout_params);

      // ...add to FrameLayout
      framelayout.addView(edittext);

      // Cocos2dxGLSurfaceView
      mGLView = new Cocos2dxGLSurfaceView(this);

      // ...add to FrameLayout
      framelayout.addView(mGLView);

      mGLView.setEGLContextClientVersion(2);
      mGLView.setCocos2dxRenderer(new Cocos2dxRenderer());
      mGLView.setTextField(edittext);

      // Set framelayout as the content view
      setContentView(framelayout);
    } else {
      Log.d("activity", "don't support gles2.0");
      finish();
    }
  }