Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 916
Burak Avatar asked Mar 10 '14 09:03

Burak


3 Answers

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.

like image 120
Rashid Avatar answered Nov 05 '22 11:11

Rashid


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.

like image 42
GrIsHu Avatar answered Nov 05 '22 10:11

GrIsHu


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.

like image 36
mushahid Avatar answered Nov 05 '22 10:11

mushahid