title: cocos2d-x How to add Videoview and Cocos2dxGlsurfaceview in same screen?
body: <p>I am developing game in android using cocos2d-x. This is my requirements.</p>
  
  <ol>
  <li>30% of screen will covered by VideoView.</li>
  <li>70% of screen will covered by Cocos2dxGlsurfaceview.</li>
  </ol>
  
  <p><em>I have create this xml.</em></p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:gravity="center" &gt;
  
      &lt;VideoView
          android:id="@+id/videoPlayer"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_weight="7" /&gt;
  
      &lt;FrameLayout
          android:id="@+id/frmGame"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_weight="3"
          android:background="@android:color/transparent" &gt;
      &lt;/FrameLayout&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><em>This is Cocos2dxActivity.java in which I edit init() method to add VideoView.</em></p>
  
  <pre><code>package org.cocos2dx.lib;
  
  import org.cocos2dx.lib.Cocos2dxHelper.Cocos2dxHelperListener;
  
  import android.app.Activity;
  import android.content.Context;
  import android.os.Build;
  import android.os.Bundle;
  import android.os.Message;
  import android.util.Log;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.FrameLayout;
  import android.widget.VideoView;
  
  public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelperListener {
      // ===========================================================
      // Constants
      // ===========================================================
  
      private static final String TAG = Cocos2dxActivity.class.getSimpleName();
  
      // ===========================================================
      // Fields
      // ===========================================================
  
      private Cocos2dxGLSurfaceView mGLSurfaceView;
      private Cocos2dxHandler mHandler;
      private static Context sContext = null;
      private FrameLayout frmGame;
      private VideoView videoPlayer;
  
      public static Context getContext() {
          return sContext;
      }
  
      // ===========================================================
      // Constructors
      // ===========================================================
  
      @Override
      protected void onCreate(final Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          sContext = this;
          this.mHandler = new Cocos2dxHandler(this);
  
          this.init();
  
          Cocos2dxHelper.init(this, this);
      }
  
      @Override
      public void runOnGLThread(final Runnable pRunnable) {
          this.mGLSurfaceView.queueEvent(pRunnable);
      }
  
      // ===========================================================
      // Methods
      // ===========================================================
      public void init() {
  
          View v = LayoutInflater.from(this).inflate(R.layout.activity_cocos2dx_video1, null);
  
          frmGame = (FrameLayout) v.findViewById(R.id.frmGame);
          videoPlayer = (VideoView) v.findViewById(R.id.videoPlayer);
  
  
          // 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
          this.mGLSurfaceView = this.onCreateView();
  
          // ...add to FrameLayout
          framelayout.addView(this.mGLSurfaceView);
  
          // Switch to supported OpenGL (ARGB888) mode on emulator
          if (isAndroidEmulator())
             this.mGLSurfaceView.setEGLConfigChooser(8 , 8, 8, 8, 16, 0);
  
          this.mGLSurfaceView.setCocos2dxRenderer(new Cocos2dxRenderer());
          this.mGLSurfaceView.setCocos2dxEditText(edittext);
  
          // Set framelayout as the content view
          frmGame.addView(framelayout,framelayout_params);
          setContentView(frmGame);
      }
  
      public Cocos2dxGLSurfaceView onCreateView() {
          return new Cocos2dxGLSurfaceView(this);
      }
  
     private final static boolean isAndroidEmulator() {
        String model = Build.MODEL;
        Log.d(TAG, "model=" + model);
        String product = Build.PRODUCT;
        Log.d(TAG, "product=" + product);
        boolean isEmulator = false;
        if (product != null) {
           isEmulator = product.equals("sdk") || product.contains("_sdk") || product.contains("sdk_");
        }
        Log.d(TAG, "isEmulator=" + isEmulator);
        return isEmulator;
     }
  
      // ===========================================================
      // Inner and Anonymous Classes
      // ===========================================================
  }
  </code></pre>
  
  <p>But when I tried to put VideoView with Cocos2dxGlsurfaceview App crashes in init() method.</p>
  
  <p>Error : child has already a parent.you must call removeview() first.</p>
  
  <p>Please help me out what I am doing wrong.</p>