在fragment中获取Application数据
来源:互联网 发布:js中的valueof 编辑:程序博客网 时间:2024/04/29 22:32
public class MyApplication extends Application { public int getColorCount() { return 1; }}
public class TestFragment extends Fragment { @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); int test = ((MyApplication) getActivity().getApplication()).getColorCount(); Log.d("testfrag", "" + test); }
Make sure you only try to accessActivity
during or afteronActivityCreated
.
0 0
- 在fragment中获取Application数据
- 在Fragment中获取context
- 在ViewPager中获取Fragment
- fragment从activity中获取数据
- Fragment中OnActivityResult获取数据问题
- Android--fragment从activity中获取数据
- 在servlet中如何获取application实例
- 在Action中获取:request,session,application
- struts2在action中获取request、session、application,并传递数据
- 在ViewPaper中获取Fragment对象
- 如何在Fragment中获取context
- 如何在Fragment中获取Activity
- 如何在Fragment中获取context
- 怎样在Fragment中获取context
- 如何在Fragment中获取context
- 如何在Fragment中获取context
- Fragment获取数据
- 4.8.4 在Android 中fragment中获取上下文
- ubuntu自己搭建邮件服务器
- OCP-1Z0-051 第16题 Q操作符的用法
- 空格“ "在IE与FF,Chrome之间显示宽度差异问题
- poj 2385 Apple Catching
- 学习shell脚本之前的基础知识
- 在fragment中获取Application数据
- ubuntu自己搭建svn服务器
- Android服务之Service(其一)
- 学号js
- android绘制一个圆,点哪画哪,走哪动哪
- Visual Studio 2012 编译错误【error C4996: 'scanf': This function or variable may be unsafe. 】的解决方案
- Android中handler运行原理
- 寻找兄弟数字
- XDR-变长类型数组-空间管理-log