I'm having a serious problem with Rajawali library using GLSurfaceView ! I'm including a Rajawali SurfaceView into an XML Fragment but the inflate in the 'onCreateView' fails.
Actually, it works when I call the fragment in the mainActivity like this :
Fragment myFragment = new MyFragment();
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.fragment_container, myFragment);
transaction.addToBackStack(null);
transaction.commit();
However, it's not working when I call this in an OnClickListener or in the Drawer like this :
myButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
myFragment c = new myFragment ();
((MainActivity) getActivity()).changeFragment(c);
}
});
The trace give me this :
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.opengl.GLSurfaceView$GLThread.onResume()' on a null object reference
at android.opengl.GLSurfaceView.onResume(GLSurfaceView.java:562)
at org.rajawali3d.surface.RajawaliSurfaceView.onResume(RajawaliSurfaceView.java:89)
at org.rajawali3d.surface.RajawaliSurfaceView.onAttachedToWindow(RajawaliSurfaceView.java:106)
Thanks for your help :)