user3718930
user3718930

Reputation: 381

android-how to extends FragmentActivity and actionbaractivity

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

Answers (4)

UFreedom
UFreedom

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

Sanket Shah
Sanket Shah

Reputation: 4382

Just Import ActionbarActivity. you will find what u want. because ActionbarActivity automatically import FragmentActivity.

For more details try FragmentActivity link

Upvotes: -1

anujprashar
anujprashar

Reputation: 6335

If you check source of ActionBarActivity you will see that ActionBarActivity extends FragmentActivity. So you only need to extend ActionBarActivity.

Upvotes: 32

Mysterious
Mysterious

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

Related Questions