我收到此错误消息:在添加内容之前必须调用 requestFeature()。我已经在 stackowerflow 上阅读了有关此错误消息的其他问题,如果我理解正确,那就是不要在 requestFeature() 之前调用 setContentView()。但这不是我在 onCreate 方法中所做的吗?或者错误可能与其他事情有关?我很困惑,希望能得到一些帮助来解决这个错误!谢谢!
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.activity_main);
// Set screen to landscape
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
// Remove title from screen
requestWindowFeature(Window.FEATURE_NO_TITLE);
// Set screen to full screen
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
// Create a new object of GameLoop and pass this context
gameLoop = new GameLoop(this);
gameLoop.setOnTouchListener(this);
setContentView(gameLoop);
}
编辑:LogCat
04-25 08:19:07.937: I/ApplicationPackageManager(6365): cscCountry is not German : NEE
04-25 08:19:08.085: W/dalvikvm(6365): threadid=9: thread exiting with uncaught exception (group=0x40018578)
04-25 08:19:08.101: E/AndroidRuntime(6365): FATAL EXCEPTION: Thread-10
04-25 08:19:08.101: E/AndroidRuntime(6365): java.lang.NullPointerException
04-25 08:19:08.101: E/AndroidRuntime(6365): at com.android.mergemania.GameLoop.drawObjects(GameLoop.java:78)
04-25 08:19:08.101: E/AndroidRuntime(6365): at com.android.mergemania.GameLoop.run(GameLoop.java:63)
04-25 08:19:08.101: E/AndroidRuntime(6365): at java.lang.Thread.run(Thread.java:1019)