Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 414
user3718930 Avatar asked Aug 12 '14 05:08

user3718930


2 Answers

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

like image 74
anujprashar Avatar answered Sep 25 '22 17:09

anujprashar


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
like image 7
UFreedom Avatar answered Sep 26 '22 17:09

UFreedom