I am using eclipse for android development and last time I used it couple of months ago with API-17. But today when installing new updates from SDK manager, I am trying to create a new project. And after creation my activity is extending ActionBarActivity instead of activity. And its showing errors. Any solutions?
Plus I got the below 2 lines of importing showing error:
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBar;
you can manually remove these if you dont need them, but they are very useful as it creates overflow menu, action bar for lower android version of its own
Import the AppCompat library into Eclipse (you may have to download it from the SDK Manager first). ActionBarActivity works the same as a normal Activity, except some method names are slightly different, e.g. getSupportActionBar() instead of getActionBar() and getSupportFragmentManager() instead of getFragmentManager().
Related
I recently updated eclipse, SDK and my problems are
By default it takes fragment_main.xml
Extends default activity to ActionBarActivity
By default it is adding the library appcompat 7
I dont have any issues with adding the library, but when i am trying to run then it is not executing in the device(2.3 android). I noticed it and changed to Activity.
If i extends it to Activity and run it and again for the next time the same problem arises while creating new Activity like...
Creating 2 xml files with extending ActionBarActiity.
I just want the new class to extend Activity but not ActionBarActivity where my target device is 2.3 and above without downgrading it
ActionBarActivity extends FragmentActivity and provides a nice bar(hehe) above your layout. Your editor is doing it correctly. ActionBarActivity was added in newer version of the sdk and it was added in the support library for older versions using appcompact v7(api 8). So most probably your development enviroment is correct. My guess is you need to check your imports and import ActionBarActivity from the support package.
It comes in SDK v4.4 . It is a plus point for developers because developers don't need to manually add the ActionBarActivity into their project. There are two solutions for your problem.
Downgrade your SDK to 4.3 or lower.
or
Remove ActionBarActivity and extends Activity in your java file.
Both will work for you.
I downloaded the ADT Bundle directly from android website for my mac. Everything was fine until I created a new project, and eclipse created my project as well as a folder named "appcompat_v7".
But I don't it, because that way I can't follow the tutorial, since you can't extend a method more than 1 time for example:
public class MainActivity extends ActionBarActivity
What can I do ? I can't follow any tutorial. I was trying this one (https://www.youtube.com/watch?v=E780gbh6vLU) and I can't because I have that appcompat_v7 project. The same happens with this one (http://code.tutsplus.com/tutorials/android-sdk-create-a-barcode-reader--mobile-17162)
Please I really need help, for my university project.
You can make it extend Activity and use the android.app.* versions of various classes (Activity, Fragment, etc) instead. IN your styles.xml, make your base style extend an Android-provided theme (like Theme.Holo) instead of the AppCompat one.
I came across this article but this article suggests replacing the FragmentActivity's code with that of the old Activity code. I can do that but would like to know if there's a way to just create Activity instead. I updated to ADT v22.6 today. Could that be the problem?
Another problem is that this requires a min-SDK of 7 while right now I want a min-SDK of 3.
Also, I am using Eclipse and not Android Studio.
Thanks in advance!
The new ADT 22.6 has new feature added that it will automatically create the any new activity as FragmentActivity not an single activity. So if you wish to create an Activity you can create it by explicitly creating separate class and extends Activity.
I'm afraid that google is enforcing us to use fragments activities instead of plain activities now. You either can go back to an SDK previous to 22.6 or just create the activities by just extending the class, adding a layout and adding the activity reference to the manifest.
I just added ActionBarSherlock to my project using these instructions, and the project compiled. But I haven't been able to actually use the library. Trying to use getSupportActionBar() just yields a Cannot resolve method error.
I'm referencing the library at the top of the class. Actually, import com.actionbarsherlock.app.ActionBar and import com.actionbarsherlock.* came up in the suggestions dialog, but I've tried both separately, and both come with the warning Unused import statement. So it seems my project doesn't actually know there's a connection between getSupportActionBar() and the ActionBarSherlock library. Any ideas on why/how to fix it?
I bet that you extend an Activity and not a SherlockActivity
Also do not forget to use a Sherlock Theme
Is there any tutorial available on the net about using support library? I am little confused because in my activity I imported all the widgets from a support library and I still get markers that say I need api 11. Do I have to extend FragmentActivity instead of Activity to use it?
EDIT:
My problem was that I extended Activity instead of FragmentActivity. This problem is mentioned here: getLoaderManager().initLoader() doesn't accept 'this' as argument though the class (ListFragment) implements LoaderManager.LoaderCallbacks<Cursor>
Here is a good explanation on how to use the support library.
Regarding FragmentActivity, you have to use it if you are trying to use a Fragment in an Activity.
Also be careful to import the proper classes. An example for a Fragment:
import android.support.v4.app.Fragment;
instead of
import android.app.Fragment;