Burak
Burak

Reputation: 478

Eclipse creates fragment layout automatically, how can i disable it

I dont want to use fragments and fragment layout. Is this possible to disable eclipse's that property? Firstly, i create a class and xml files then i declare them in Android Manifest file this works for me but it takes a long time if i can disable it, it will be easier.

http://i.hizliresim.com/KgMJvQ.png

Upvotes: 8

Views: 15342

Answers (10)

Mubarrat Hasan
Mubarrat Hasan

Reputation: 304

Choose Empty Activity instead of creating Blank Activity if you don't find the Empty Activity option, you have chosen a newer version of the software instead of the updated version software.

Upvotes: 0

Burak
Burak

Reputation: 478

Android heard our voice :).

Just upgrade or download ADT version to 23.0.2 or higher.

Now you can choose blank activity like this,

enter image description here

Upvotes: 0

mushahid
mushahid

Reputation: 514

Create a Blank Activity project with Navigation type as none and other entries as default.

Copy the contents of fragment_main.xml into activity_main.xml and delete the fragment _main.xml

Now go to MainAcitvity.java remove only this portion from MainActivity onCreate() method:

if (savedInstanceState == null) {
    getSupportFragmentManager().beginTransaction()
        .add(R.id.container, new PlaceholderFragment())
            .commit();
   }  

finally remove class PlaceholderFragment{} and its contents from MainActivity.java and then run your application.

Upvotes: 1

user3779607
user3779607

Reputation: 1

When you are creating a new Android Application Project using the wizard, after you get to the screen that asks you to select type of activity, choose Empty Activity instead of Blank Activity, which is the default.

No fragments will be created.

Upvotes: -1

Edel Custodio
Edel Custodio

Reputation: 1

You just put the same name that your "Layout Name" in "Fragment Layout Name" and the wizard will not create the fragment file

Upvotes: -1

Rashid
Rashid

Reputation: 512

While creating new Application, just copy the Layout Name to the Fragment Layout Name(eg:activity_main)

Voila! You get an activity without the fragment part.

remove this part of the code from activity

if (savedInstanceState == null) {
        getSupportFragmentManager().beginTransaction()
                .add(R.id.container, new PlaceholderFragment())
                .commit();

Clean the project.

Upvotes: 2

Hari_krish4
Hari_krish4

Reputation: 149

I done it by replacing the BlankActivity(22.6.2) folder to the older sdk BlankActivity(22.6.1) present in the tools/templates directory in android-sdk.

Upvotes: 0

saran
saran

Reputation: 413

You might wanna try this. ADT blank activity created with fragment activity..

It works fine for me, when it comes to creating blank activities, without fragments.

Upvotes: 0

Georgie
Georgie

Reputation: 2475

There appears to be no setting to accomplish what you want at the moment (I agree there should be one). As a workaround, this answer to a similar question shows how to remove fragments from the newly created project. https://stackoverflow.com/a/22482259/1287459

Upvotes: 0

GrIsHu
GrIsHu

Reputation: 23648

Eclipse provides a facility to create a Simple Android Application which does not contains any Fragment classes or Layout files.

You can just create simple project besides selecting any kind of templates for the project.

Upvotes: 1

Related Questions