我有一个主要活动,并召唤其他活动来显示一些数据。
I have a main activity, and it summons another activity to display some data.
我有我整个的主要活动code。使用专用数据库辅助对象。有没有一种方法,以我的主要活动范围内传递给我的子活动在一个优雅的方式? (即从子类,像 getCallingActivityContext())
I have a private database helper object that I use throughout the main activity code. Is there a way to pass the context of my main activity to my sub activity in an elegant way? (ie, from subclass, something like getCallingActivityContext())
我总是可以创建新的数据库辅助对象。
I could always create new database helper objects.
推荐答案扩展应用程序类可以帮助你允许申报/访问全局变量。您可以设置从任何活动的变量的ApplicationContext 和其他活动访问它,而无需使用包。
Extending the Application class helps you to allow declare/access global variables. You can set your variables from any activity to ApplicationContext and access it from other activity without using bundle.
Android的:?如何声明全局变量会帮你
更多推荐
如何从活动通过上下文活动?
发布评论