posts - 189,comments - 115,trackbacks - 0
          保存全局變量在appliation不管activty的轉換
          public
           class MyApplication extends Application { 
           
              
          private String someVariable; 
           
              
          public String getSomeVariable() { 
                  
          return someVariable; 
              
          } 
           
              
          public void setSomeVariable(String someVariable) { 
                  
          this.someVariable = someVariable; 
              
          } 
          } 
          <application android:name="MyApplication" android:icon="@drawable/icon" android:label="@string/app_name"> 
          // set 
          ((MyApplication) this.getApplication()).setSomeVariable("foo"); 
           
          // get 
          String s = ((MyApplication) this.getApplication()).getSomeVariable(); 
          posted on 2010-08-26 19:39 MEYE 閱讀(181) 評論(0)  編輯  收藏 所屬分類: Android3D
          主站蜘蛛池模板: 自治县| 韶关市| 汉中市| 鸡东县| 贵溪市| 奎屯市| 玛纳斯县| 大连市| 潮安县| 甘德县| 玛曲县| 黑山县| 沽源县| 永年县| 巩留县| 察雅县| 正阳县| 大冶市| 盘山县| 白沙| 怀集县| 南安市| 收藏| 衡山县| 精河县| 白山市| 潞城市| 苍溪县| 铜川市| 交城县| 武汉市| 荥经县| 丰宁| 关岭| 龙井市| 偃师市| 商水县| 邹城市| 曲阜市| 栖霞市| 乾安县|