2014-09-20 66 views
0

如何更改首選項屏幕的TextEdit的值,我想要修改MainActivity的TextEdit。我該怎麼做?。改變preferenceScreen的textEdit時如何設定值微調器?

@Override 
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, 
     String key) { 
    if (key.equals(PrefUserName)) { 

     SharedPreferences sharedPref = PreferenceManager 
       .getDefaultSharedPreferences(getApplication()); 

     String textoEditTextPreference = sharedPref.getString(key, 
       ""); 
     // Spinner spinner = (Spinner) findViewById(R.layout.activity_main); 


     //Here I want add value spinner of main activity... 
     // Spinner spinner = (Spinner) findViewById(R.layout.activity_main); 

     Toast.makeText(
       getApplication(), 
       "New name of user: " 
         + textoEditTextPreference, Toast.LENGTH_SHORT) 
       .show(); 
    } 
+0

嗨,你能解決您的一個評論那裏identation,這是代碼? – 2014-09-20 12:20:06

回答

0

至於我能理解你的問題是什麼: 您應該使用SharedPreference編輯

SharedPreferences.Editor prefEditor = sharedPref.edit(); 
prefeditor.putString(key, ""); 
prefeditor.commit(); 
相關問題