After the ADT update in eclipse whenever I create a new project for android a default fragment activity is created. How to get to create simple activity always?
I don't want to downgrade the ADT.
Is this possible? any work around?
The latest ADT plugins are made in such a way that if you create any simple project you will always get the FragmentActivity not a simple Activity. And you can not change it.
In new ADT itself there is Blank Activity that is defined with an actionbar and optional navigational elements such as tabs or horizontal swipe.
If you want to create simple activity in your project then you can simply create class and extends Activity into it, this is the only way now. Or you can change the Fragment with Activity simply by changing code only.
As an Activity is simply a Java class, just accept the defaults the ADT gives you during the initial creation of your project. Create your project, then manually:
1. Delete all the class and layout files in your project.
2. Create your Java class files extending Activity (in your desired packages).
3. Create XML layout files (in the res/layout folder).
4. 'Wire-up' your Java class files and XML layout files using setContentView(R.layout.YOUR_LAYOUT_ID) in the onCreate() methods.
5. Done!
EDIT
Remember to Register your Activities in the Manifest manually as well.
Related
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 have been using Android ADT for a few weeks now and i used to normally create new activities by going to:File>New>Other>Android>Android_Activity>Blank_Activity. However after updating my 'Android SDK Tools' & 'Android SDK Platform Tools' today , its now showing a new option when I'm trying to create an activity.
When I select new blank activity and click next , its then showing a new form that i have to fill in which is titled as 'Fragment Layout Name'. Why has this suddenly appeared and does anyone know why I'm being forced to create a fragment layout as i don't want to even use this. I also remember one of my friends saying that he updated his SDK about a week ago and he stated that he had the same problem. Shall i just remove the fragment in the XML document once its loaded or is there a way to disable this so i wont have to go through this every-time.
The templates of files produced by "New ..." wizard have changed lately. Now you are enforced to create a new Activity with a Fragment placeholder attached. Guess that's the way the developers enforce people to build UI based on Fragments :)
There are a few workarounds for your problem:
1) Just delete fragment layout in your resources; delete the placeholder fragment in your Activity code and all the relevant code (FragmentManager etc); change activity layout from FrameLayout to anything you like.
2) Follow the recipe proposed in this answer
3) Don't. Ever. Use. Wizards. It is much better to create a new class and write extends Activity (or Fragment, Service, etc), than to create a template and waste your precious time changing it to your needs. And it helps to understand the lifecycle of components, too.
I just want to make a simple Hello world app that extends Activity but when I create a new android project it add all this extra stuff. It didn't use to do it before,but now everytime I create a project it extends ActionBarActivity and creates a fragment layout and has code for fragments and its no longer the simple project I used to be able to create.
How do I fix this?
I too had the same problem and this is how I fixed it.
When you create new Android Application Project, select Minimum Required SDK as API 14 or above.
If you want to support API level < 14 you can change the "minSdkVersion" in AndroidManifest.xml manually after creating the project.
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.
When I create a "New Android Application Project," I would like Eclipse to proceed with its normal actions with (at least) one customization.
I want Eclipse to create the new Activity.Class file using fuller #Overrides rather than just the onCreate(), such as also providing onStart(), onResume(), onPause(), onRestart(), and so on.
In other words, I want a more verbose Activity.Class file generated than is already done by Eclipse.
Going further, I would also like Eclipse to add my own inner classes - if that is not asking too much.
In short, is there a template in Eclipse that I can tailor for this customization?
I am not aware of a way to accomplish this within the "New Android Application Project Dialog", but you add additional overrides to each activity yourself by clicking the Source dropdown menu, then Override/Implement methods..., and then select each method you would like to override.
I'm not sure what you mean by add your own inner classes. You can do this easily yourself, I'm not sure what additional functionality Eclipse could provide.
This might answer your question. There's a templates directory in your Android SDK where you can add or alter the XML templates.
Good luck,
Bp