I want to use LibGDX with Android, but instead of modifying my Activity to extend


I want my to render my graphics inside Android Fragment

The problem is that my class already extends Fragment, so I can't make it extend LibGDX AndroidApplication (Multiple Inheritance)

is there any workaround for this ?


  • \$\begingroup\$ You would probably just complicate things by taking out pretty much one of the core features of libgdx. Where does the need come from to make it so complex? \$\endgroup\$ – Sidar Nov 25 '12 at 23:15
  • \$\begingroup\$ I need to display a 3D model in the fragment, then display some info in another view in the activity \$\endgroup\$ – Mina Wissa Nov 26 '12 at 7:58
  • \$\begingroup\$ If I'm not mistaken libgdx supports 3D rendering. Not sure though. \$\endgroup\$ – Sidar Nov 26 '12 at 13:46
  • \$\begingroup\$ Seems like it's still in progess: libgdx.badlogicgames.com/features.html Sorry can't help you there =[ \$\endgroup\$ – Sidar Nov 26 '12 at 15:51

Ok, after searching I got this solution:

instead of using a fragment I used a generic View to render my graphics in it:

game=new MyGdxGame(); 
View gameView=initializeForView(game,cfg);

this is how I was able to display other views in my activity


I just made a pull request with the fragment feature implemented.

Instead of extending AndroidApplication by an activity, you can extend AndroidFragmentApplication by a Fragment and return initializeForView() on the onCreateView callback.

  • 1
    \$\begingroup\$ Thanks a lot, maybe you want to share the url of your repo to help other users with this \$\endgroup\$ – Mina Wissa Feb 4 '14 at 13:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.