android
来源:互联网 发布:数控折弯机编程视频 编辑:程序博客网 时间:2024/05/15 19:42
通过Application传递参数:
1、自定义一个MyApplication如:
package com.jxj.androidlife;
import android.app.Application;
public class MyApplication extends Application {
private String empNo;
@Override
public void onCreate() {
super.onCreate();
this.setEmpNo("001");
}
public String getEmpNo) {
return empNo;
}
public void setEmpNo(String empNo) {
this.empNo = empNo;
}
}
2、在AndroidManifest中设置id:
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
。。。。。
改成如下:
<application
android:name=".MyApplication"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
3、
通过下面代码即可获取到Application
MyApplication myApp=(MyApplication)this.getApplication();
- Android
- android
- Android
- android
- android
- Android
- Android
- android
- android
- android
- Android
- Android
- android!!!
- android
- android
- android
- android
- android:
- 第三天--java流程控制语句
- node.js开发之RBAC用户角色权限设计方案
- Spring学习笔记1——基础知识
- Java实现俄罗斯方块
- 个人重构机房收费系统——类图
- android
- 给循环定义标记,指定跳出和结束循环体
- cocos2dx弱联网
- 获取Android IP信息
- 1. 整型
- 配合 GitHub -- Git 的基础使用
- 2. 浮点型
- 属性抽取和打分:一种概率方法(ICDE2013)
- cocos2dx本地差异化