activity_main.xml与fragment_main.xml

见:

http://blog.sina.com.cn/s/blog_3e28c8a50101fqvw.html

http://blog.sina.com.cn/s/blog_3e28c8a50101fqb8.html

创建了一个低版本的Android project

在创建project时(低级菜鸟级别,只做笔记用)可能是由于安装的ADT版本高???

若选择create activity时仍然会有fragment_main.xml

但是创建工程后在mainactivity中仍旧有

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

// public static class PlaceholderFragment extends Fragment {
//
// public PlaceholderFragment() {
// }
//
// @Override
// public View onCreateView(LayoutInflater inflater, ViewGroup container,
// Bundle savedInstanceState) {
// View rootView = inflater.inflate(R.layout.hello_world1, container,
// false);
// return rootView;
// }
// }

project创建成功后

res-layout下面就只有activity_main.xml

工程会报错container cannot be resolved or is not a field

把上面的有关Fragment的代码注释掉 clean就好了

原文地址:https://www.cnblogs.com/Pierre-de-Ronsard/p/3926623.html