Eclipse creates fragment layout automatically, how can i disable it

15,289

Solution 1

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

Solution 2

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.

Solution 3

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.

Solution 4

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.

Share:
15,289
Burak
Author by

Burak

Updated on August 02, 2022

Comments

  • Burak
    Burak over 1 year

    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

  • Burak
    Burak about 10 years
    I've edited my question, there are screenshots, where is my mistake?
  • GrIsHu
    GrIsHu about 10 years
    Which ADT you are having ? I guess now the latest ADT have kept the functionality of adding the layout of fragments into the default structure also. That is why its showing options to add the fragment layout name. Whereas it doesnot show in my eclipse.
  • Burak
    Burak about 10 years
    I've the latest version (ADT 22.6)
  • GrIsHu
    GrIsHu about 10 years
    That is why its showing option for the fragment layout name setting.
  • Burak
    Burak about 10 years
    But i don't want to create fragment so how can i do?
  • GrIsHu
    GrIsHu about 10 years
    If you do not want to create a fragment then you can simply that classes from your structure.
  • Burak
    Burak about 10 years
    I know i can do that but i don't want to do this every time. I think it mustn't be mandatory.
  • GrIsHu
    GrIsHu about 10 years
    Yes i know it must not be mandatory but if its added into latest ADT then it will always come by default. As i can see in your SS it has made compulsory to add the name of fragment class also.
  • Burak
    Burak about 10 years
    Also i don't know why did he/she vote down my question. If you have any idea you DO NOT do anything. Whatever, thank you for your ideas @GrlsHu