Eclipse 自动创建片段布局,如何禁用它

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22296188/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 21:34:27  来源:igfitidea点击:

Eclipse creates fragment layout automatically, how can i disable it

androideclipseandroid-fragmentsfragmentandroid-fragmentactivity

提问by Burak

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.

我不想使用片段和片段布局。这可以禁用 eclipse 的那个属性吗?首先,我创建了一个类和 xml 文件,然后我在 Android Manifest 文件中声明它们这对我有用,但是如果我可以禁用它需要很长时间,它会更容易。

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

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

采纳答案by Burak

Android heard our voice :).

Android 听到了我们的声音:)。

Just upgrade or downloadADT version to 23.0.2 or higher.

只需将ADT 版本升级或下载到 23.0.2 或更高版本即可。

Now you can choose blank activity like this,

现在你可以选择这样的空白活动,

enter image description here

enter image description here

回答by Rashid

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

创建新应用程序时,只需将布局名称复制到片段布局名称(例如: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.

清理项目。

回答by mushahid

Create a Blank Activity projectwith Navigation typeas noneand other entries as default.

创建Blank Activity project导航型没有和其他条目为默认值。

Copy the contents of fragment_main.xmlinto activity_main.xmland delete the fragment _main.xml

将内容复制fragment_main.xmlactivity_main.xml并删除fragment _main.xml

Now go to MainAcitvity.javaremove only this portion from MainActivityonCreate()method:

现在MainAcitvity.javaMainActivityonCreate()方法中只删除这部分:

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

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

最后PlaceholderFragment{}从中删除类及其内容MainActivity.java,然后运行您的应用程序。

回答by GrIsHu

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

Eclipse 提供了一种创建简单 Android 应用程序的工具,该应用程序不包含任何Fragment类或布局文件。

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

除了为项目选择任何类型的模板之外,您还可以创建简单的项目。

回答by Georgie

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

目前似乎没有设置可以完成您想要的操作(我同意应该有一个)。作为解决方法,此对类似问题的回答显示了如何从新创建的项目中删除片段。 https://stackoverflow.com/a/22482259/1287459

回答by saran

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

你可能想试试这个。 使用片段活动创建的 ADT 空白活动..

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

在创建空白活动时,它对我来说很好用,没有碎片。

回答by Hari_krish4

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.

我通过将 BlankActivity(22.6.2) 文件夹替换为 android-sdk 的 tools/templates 目录中的旧 sdk BlankActivity(22.6.1) 来完成它。

回答by Jonathan Carsalade

  • First you need to downgrade your ADT plugin for eclipse :
    Go to Help > Install New Sofware... and click on the blue link : What is already installed ?
    Then select "Tracer for OpenGL ES" and all the Softwares containing "Android" and click Uninstall. When it's done, download ADT plugin for eclipse (revision 22.3.0) here :
    http://dl.google.com/android/ADT-22.3.0.zip

    Now we are going to install it in eclipse. Go to Help > Install New Sofware... and click on "Add" and then "Archive". Browse the archive we have just download and click "OK". Select all the items in the list and click "Next".


  • At this time you need to downgrade your android sdk tools :
    First remove your android sdk tools folder.
    Then download the tools (revision 22.3) here :
    http://dl-ssl.google.com/android/repository/tools_r22.3-windows.zip

    Then extract it and copy the tools folder inside your android sdk folder.


    Do not update eclipse ADT plugin and android tools (in sdk manager).
  • 首先,您需要为 Eclipse 降级 ADT 插件:
    转到“帮助”>“安装新软件...”,然后单击蓝色链接:已安装什么?
    然后选择“Tracer for OpenGL ES”和所有包含“Android”的软件,然后单击“卸载”。完成后,请在此处下载 eclipse 的 ADT 插件(修订版 22.3.0):
    http: //dl.google.com/android/ADT-22.3.0.zip

    现在我们将在 eclipse 中安装它。转到“帮助”>“安装新软件...”,然后单击“添加”,然后单击“存档”。浏览我们刚刚下载的档案,然后单击“确定”。选择列表中的所有项目,然后单击“下一步”。


  • 这时候你需要降级你的android sdk工具:
    首先删除你的android sdk工具文件夹。
    然后在此处下载工具(修订版 22.3):
    http: //dl-ssl.google.com/android/repository/tools_r22.3-windows.zip

    然后解压缩并将工具文件夹复制到您的 android sdk 文件夹中。


    不要更新 eclipse ADT 插件和 android 工具(在 sdk 管理器中)。

回答by Edel Custodio

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

您只需在“片段布局名称”中输入与“布局名称”相同的名称,向导就不会创建片段文件

回答by user3779607

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.

当您使用向导创建新的 Android 应用程序项目时,在您进入要求您选择活动类型的屏幕后,选择 Empty Activity 而不是 Blank Activity,这是默认设置。

No fragments will be created.

不会创建任何片段。