使用片段活动创建的ADT空白活动。
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...
我现在很困惑,因为每当我创建一个新的android应用程序时,它总是带有fragment_main.xml。我只是想创建一个没有片段的空白活动……
in the first image the blank activity comes with the fragment layout..
在第一张图片中,空白的活动伴随着片段布局。
the second image shows the created fragment_main
第二个映像显示了创建的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#=
现在我真的很困惑……这只发生在更新了ADT到最新版本之后,我已经提到了这个线程:https://stackoverflow.com/questions/22203862/adt- create-default-hello- worldbut -command-line-do #=。
i just wanted to make an android app with blank activity with no fragment view...
我只是想做一个没有片段视图的空白活动的android应用。
15 个解决方案
#1
27
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.
1)复制res/layout/fragment_main.xml的所有内容。activity_main开放。xml,删除框架布局,并粘贴复制的内容。
2) Delete fragment_main.xml
2)删除fragment_main.xml
3) In MainActivity.java, delete the whole PlaceHolderFragment class:
3)在MainActivity。java,删除整个PlaceHolderFragment类:
/**
* 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():
4)从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.
此时,您应该已经设置好运行项目。
更多相关文章
- 问题记录-Activity跳转后显示空白界面
- Android有用的代码片段
- 这些片段在Android编程中很有用
- ViewPager中的错误片段接收onContextItemSelected调用
- 键盘打开时,带有片段的活动不会调整大小
- 嵌套片段不保留其状态