0

我有一个实现 OpenGL 的程序,glSurfaceView 位于根布局(相对布局)中。当我调用 public void onCreate(Bundle savedInstanceState) 函数时,我只从 OpenGL 中获取绘图,而没有得到我拥有的其他布局。为什么会这样?这是我的代码:

包 com.reea.red;

import android.app.Activity;
import android.opengl.GLSurfaceView;
import android.os.Bundle;
import android.view.View;

  public class AvatarCreator extends Activity {
/** Called when the activity is first created. */
private static int tab=3;
private GLSurfaceView glSurfaceView;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    glSurfaceView = new GLSurfaceView(this);
    // set our renderer to be the main renderer with
    // the current activity context
    glSurfaceView.setRenderer(new GlRenderer(this));
    setContentView(R.layout.main);
    setContentView(glSurfaceView);
   // findViewById(R.id.linearLayout1).setVisibility(View.VISIBLE);


    //setContentView(R.layout.main);
}

public static int getTab() {
    return tab;
}

public static void setTab(int tab) {
    AvatarCreator.tab = tab;
}

}

4

1 回答 1

1

我设法使它与这段代码一起工作:

super.onCreate(savedInstanceState);


    setContentView(R.layout.main);

    final GridView gridview = (GridView) findViewById(R.id.gridView1);
    final ImageAdapter adapter=new ImageAdapter(this);

    mGLView = (GLSurfaceView)findViewById(R.id.glSurface); 

    mGLView.setEGLConfigChooser(8,8,8,8,16,0);

    mGLView.setRenderer(new HelloOpenGLES10Renderer(this));
    mGLView.getHolder().setFormat(PixelFormat.TRANSLUCENT);
    mGLView.setZOrderOnTop(true);

    this.mGLView = (GLSurfaceView) this.findViewById(R.id.glSurface);
于 2012-06-26T07:06:08.133 回答