Reputation: 381
I'm using fragments on my activity and also I need actionbar too. for having actionbar on android 2.2+, I need to extend actionbar activity and I need to extends FragmentActivity too.
Java doesn't let us to extend two classes.
What is the solution? How can I do so?
Upvotes: 17
Views: 10276
Reputation: 79
You can link to the develop website: https://developer.android.com/reference/android/support/v7/app/ActionBarActivity.html
As you look, class ActionBarActivity
extends FragmentActivity
,So you just need to extends ActionBarActivity
.
java.lang.Object
↳ android.content.Context
↳ android.content.ContextWrapper
↳ android.view.ContextThemeWrapper
↳ android.app.Activity
↳ android.support.v4.app.FragmentActivity
↳ android.support.v7.app.ActionBarActivity
Upvotes: 7
Reputation: 4382
Just Import ActionbarActivity
. you will find what u want. because ActionbarActivity
automatically import FragmentActivity
.
For more details try FragmentActivity link
Upvotes: -1
Reputation: 6335
If you check source of ActionBarActivity
you will see that ActionBarActivity
extends FragmentActivity
. So you only need to extend ActionBarActivity.
Upvotes: 32
Reputation: 173
First of all why you wanna extend both FragmentActivty and ActionBarActivity ?
because ActionBarActivity will work for you, and to make your app compatible with lower versions, you should import android-support-v7-appcompat in your project
Upvotes: 1