Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android

What should I do if my MainActivity extends from ActionBarActivity?

Hi everyone, my MainActivity extends from ActionBarActivity as shown below,what should I do? Should I still change it into "public class MainActivity extends FragmentActivity"? Thanks!

public class MainActivity extends ActionBarActivity implements ActionBar.TabListener {

   public static final String TAG=MainActivity.class.getSimpleName();
   //ignore the rest
}

1 Answer

ActionBarActivity "extends" FragmentActivity. So, basically, you can use it in it's place.

To see this for yourself, in your IDE (Eclipse or Android Studio), you should be able to ctrl+click on ActionBarActivity and be taken to the source code for it. You'll see that it more accurately extends android.support.v4.app.FragmentActivity. And, the teacher's notes for that course provide additional info for using the FragmentActivity from the support library.

More info: https://developer.android.com/reference/android/support/v7/app/ActionBarActivity.html

thanks :) 謝謝你