如何将应用程序对象放入片段类 [英] How to get application object into fragment class
本文介绍了如何将应用程序对象放入片段类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在更改我的android移动应用程序以同时支持平板电脑和手机.为此,我将活动类更改为片段.在我的活动类中,我的应用程序类的实例创建如下:
I am changing my android mobile app to support both tablets and mobile phone. For this I am changing my activity class into fragment. In my activity class I have an instance of my application class created as below:
appCtx = (UnityMobileApp) getApplication();
UnityMobileApp
是我的Application类.
Where UnityMobileApp
is my Application class.
现在,我想在我的片段类中创建相同的实例.你们能帮我解决这个问题吗?
Now I want to create the same instance in my fragment class. Can you guys please help me solve this?
推荐答案
在片段中使用appCtx = (UnityMobileApp) getActivity().getApplication();
.
这篇关于如何将应用程序对象放入片段类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文