刚学习安卓开发,简单例子写了一遍,结果用模拟器运行到时候,提示Unfortunately,Activity has stopped.
刚开始学习安卓开发,对着书上到一个简单例子写了一遍,结果用模拟器运行到时候,总是提示Unfortunately,Activityhasstopped.,代码很少,希望知道...
刚开始学习安卓开发,对着书上到一个简单例子写了一遍,结果用模拟器运行到时候,总是提示Unfortunately,Activity has stopped.,代码很少,希望知道的能帮助解决一下,不胜感激。
第一段代码
package com.example.game;
import android.opengl.GLSurfaceView;
import android.os.Bundle;
import android.app.Activity;
public class MainActivity extends Activity {
private GLSurfaceView gameview;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
gameview=new GLSurfaceView(this);
setContentView(gameview);
}
@Override
protected void onResume(){
super.onResume();
gameview.onResume();
}
@Override
protected void onPause(){
super.onPause();
gameview.onPause();
}
}
第二段代码
package com.example.game;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
import android.opengl.GLSurfaceView.Renderer;
public class GAMERenderer implements Renderer {
@Override
public void onDrawFrame(GL10 gl) {
gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
}
@Override
public void onSurfaceChanged(GL10 gl, int width, int height) {
gl.glViewport(0, 0, width, height);
}
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig arg1) {
gl.glClearColor(1.0f, 0.0f, 0.0f, 0.0f);
}
} 展开
第一段代码
package com.example.game;
import android.opengl.GLSurfaceView;
import android.os.Bundle;
import android.app.Activity;
public class MainActivity extends Activity {
private GLSurfaceView gameview;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
gameview=new GLSurfaceView(this);
setContentView(gameview);
}
@Override
protected void onResume(){
super.onResume();
gameview.onResume();
}
@Override
protected void onPause(){
super.onPause();
gameview.onPause();
}
}
第二段代码
package com.example.game;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
import android.opengl.GLSurfaceView.Renderer;
public class GAMERenderer implements Renderer {
@Override
public void onDrawFrame(GL10 gl) {
gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
}
@Override
public void onSurfaceChanged(GL10 gl, int width, int height) {
gl.glViewport(0, 0, width, height);
}
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig arg1) {
gl.glClearColor(1.0f, 0.0f, 0.0f, 0.0f);
}
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询