# Using LibGDX within Android Fragment

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

AndroidApplication

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 ?

Thanks

• 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? – Sidar Nov 25 '12 at 23:15
• I need to display a 3D model in the fragment, then display some info in another view in the activity – Mina Samy Nov 26 '12 at 7:58
• If I'm not mistaken libgdx supports 3D rendering. Not sure though. – Sidar Nov 26 '12 at 13:46
• Seems like it's still in progess: libgdx.badlogicgames.com/features.html Sorry can't help you there =[ – 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.

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