展会信息港展会大全

继承Application类设置全局变量。在任何Activity中都可以通过ge...
来源:互联网   发布日期:2016-01-14 11:33:07   浏览:1846次  

导读:public class MyApplication extends Application { private String someVariable; public String getSomeVariable() { return someVariable; } public void setSomeVariable(String someVariable) { this.someVariable = someVariable; } } // set ((MyAppl...

public class MyApplication extends Application {

private String someVariable;

public String getSomeVariable() {

return someVariable;

}

public void setSomeVariable(String someVariable) {

this.someVariable = someVariable;

}

}

// set

((MyApplication) this.getApplication()).setSomeVariable("foo");

// get

String s = ((MyApplication) this.getApplication()).getSomeVariable();

赞助本站

人工智能实验室

相关热词: android开发 android教程

AiLab云推荐
推荐内容
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港