在这段代码中,我在boolean
类中将这些false
变量设置为Globals
。但是,在运行时,当我通过在Activity
中对其进行调用并将本地boolean
设置为Globals
boolean
s的值时,它们会给出一个{{ 1}}的值。我不知道为什么会这样。
true
类:
Globals
主要活动(省略了导入):
package com.example.ymarebuild;
import android.app.Application;
public class Globals extends Application {
private static Globals instance;
private static boolean u1t1 = false;
private static boolean u1t2 = false;
private static boolean u1t3 = false;
private static boolean u1t4 = false;
private Globals(){}
public void setu1t1(boolean a){
Globals.u1t1=a;
}
public boolean getu1t1(){
return Globals.u1t1;
}
public void setu1t2(boolean a){
Globals.u1t2=a;
}
public boolean getu1t2(){
return Globals.u1t2;
}
public void setu1t3(boolean a){
Globals.u1t2=a;
}
public boolean getu1t3(){
return Globals.u1t3;
}
public void setu1t4(boolean a){
Globals.u1t4=a;
}
public boolean getu1t4(){
return Globals.u1t4;
}
public static synchronized Globals getInstance(){
if (instance==null) {
instance = new Globals();
}
return instance;
}
}