[英]SetContentView doesn't show R.layout.main only glSurfaceView
我有一個實現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;
}
}
我設法使其與以下代碼一起使用:
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);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.