解决方案 »
- android手机管理软件怎么实现的
- 新人求助 导入整个android工程 单个文件没有报错,整个工程报错
- Android ExpandableListView 点击出错
- 移除SD卡后,程序直接被杀掉了,求解
- android 闹钟 静音 仍然响
- R.id.widget29_getName_EditText是什么东东
- google play 屏蔽我的app
- unity4.2为什么会报jni:init'd androidjavaclass with null ptr的错误
- 这是什么颜色,我怎么转化
- AlarmManager 怎样在进程被干掉的情况下触发回调
- Android里读写配置文件,用什么方法比较法?
- android如何搭建后台服务
或者把下面这段删掉,不去commit fragment if (savedInstanceState == null) {
getFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment())
.commit();
}
这里面加载的布局文件哦。
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
} @Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
} /**
* 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.4的SDK会同时有两个layout出现,目前还没搞清楚两个的关系,只能先删除一个,针对另一个操作了 :)多谢
fragment理解是activity中的一个组件,4.0以后都推荐用fragment来实现,这样可以适配pad,具体的你可以去详细阅读官方文档