Eclipse creates fragment layout automatically, how can i disable it
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,
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.
Burak
Updated on August 02, 2022Comments
-
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.
-
Burak about 10 yearsI've edited my question, there are screenshots, where is my mistake?
-
GrIsHu about 10 yearsWhich 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 about 10 yearsI've the latest version (ADT 22.6)
-
GrIsHu about 10 yearsThat is why its showing option for the fragment layout name setting.
-
Burak about 10 yearsBut i don't want to create fragment so how can i do?
-
GrIsHu about 10 yearsIf you do not want to create a fragment then you can simply that classes from your structure.
-
Burak about 10 yearsI know i can do that but i don't want to do this every time. I think it mustn't be mandatory.
-
GrIsHu about 10 yearsYes 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 about 10 yearsAlso 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