activity_main.xml与fragment_main.xml

解决Android低版本项目Fragment问题
本文记录了在创建低版本Android项目时遇到的问题及解决方法。主要涉及创建项目时出现不必要的Fragment代码,并且工程会报错。通过注释掉相关Fragment的代码并进行清理,可以解决此问题。

见:

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值