使用片段活动创建的ADT空白活动 [英] ADT blank activity created with fragment activity..

查看:138
本文介绍了使用片段活动创建的ADT空白活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在真的很困惑,因为每当我创建一个新的Android应用程序与空白的活动,它总是出来与fragment_main.xml ..我只是想创建一个空白的活动,没有片段...



在空白活动附带片段布局的第一个图像中。





第二个图像显示了创建的fragment_main





现在我真的很困惑...这只是在更新ADT到最新版本后才发生
i引用了这个线程: https://stackoverflow.com/questions/22203862/adt-doesnt-create-default-hello-world-but-command-line -does# =



我只想做一个android应用程序与空白活动,没有片段视图...

解决方案

对于那些想要如何从项目中删除片段的指令:



1)复制res / layout / fragment_main.xml的所有内容。打开activity_main.xml,删除FrameLayout并粘贴复制的内容。



2)删除fragment_main.xml



3)在MainActivity.java中,删除整个PlaceHolderFragment类:

  / ** 
*占位符片段包含一个简单的视图。
* /
public static class PlaceholderFragment extends Fragment {

public PlaceholderFragment(){
}

@Override
public查看onCreateView(LayoutInflater inflater,ViewGroup容器,
Bundle savedInstanceState){
查看rootView = inflater.inflate(R.layout.fragment_main,
container,false);
返回rootView;
}
}

4)从onCreate()中删除以下行:

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

此时您应该设置为运行该项目。 >

i am really confused right now because whenever i create a new android app with blank activity it always comes out with fragment_main.xml.. i just wanted to create a blank activity without the fragment one...

in the first image the blank activity comes with the fragment layout..

the second image shows the created fragment_main

now i am really confused... this only happened after updating ADT to the latest version i have referred to this thread: https://stackoverflow.com/questions/22203862/adt-doesnt-create-default-hello-world-but-command-line-does#=

i just wanted to make an android app with blank activity with no fragment view...

解决方案

For those who would like instructions on how to remove Fragments from the project:

1) Copy all the contents of res/layout/fragment_main.xml. Open activity_main.xml, delete the FrameLayout, and paste in the copied contents.

2) Delete fragment_main.xml

3) In MainActivity.java, delete the whole PlaceHolderFragment class:

/**
 * A placeholder fragment containing a simple view.
 */
public static class PlaceholderFragment extends Fragment {

    public PlaceholderFragment() {
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                    Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_main,
                    container, false);
        return rootView;
    }
}

4) Delete the following lines from onCreate():

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

At this point you should be all set to run the project.

这篇关于使用片段活动创建的ADT空白活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆