setContentView()
2 回目に呼び出すと、最初に設定したものを置き換えて、背景だけを残します。クラッシュは、削除されたメイン レイアウトの要素に依存している可能性が最も高いです。
を 2 回呼び出すのではなく、メイン レイアウトにsetContentView()
含める必要があります。GLSurfaceView
以下は、これを行う方法の例です。
<?xml version="1.0" encoding="UTF-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent>
<your.application.package.ClearGLSurfaceView
android:layout_width="match_parent"
android:layout_width="match_parent"/>
<!--put the rest of your layout here, i.e the contents of the original R.layout.main_pixie-->
</FrameLayout>
次に、このレイアウトを通常どおりに読み込むことができますonCreate()
(main_pixie_new は上記の xml を参照します。できるだけ明確にするためにその名前を付けただけです)。
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_pixie_new);
}