2011-05-17 32 views

回答

0

我想你正在使用Intent在你的活動之間切換。

您可以使用putExtra方法發送一些數據。 在活動中,你必須在文字編輯:

Intent intent = new Intent(this, myClass.class); 
intent.putExtra("key", "StringFromEditText"); 
startActivity(intent); 

,並得到它的活動,你有TextView的:

Bundle extras = getIntent().getExtras(); 
String content = extras.getString("key"); 
+0

它讓我在get第二位代碼時創建一個getIntent方法。 – Will 2011-05-17 15:41:03

+0

我現在感到困惑。當我打開包含editText的主要活動並單擊保存按鈕時,我希望它關閉應用程序,然後使用editText的內容更新窗口小部件的textView。 – Will 2011-05-17 15:47:49

+0

哦,我不知道這個字符串必須保存。我的代碼不適合你的需要。你應該檢查一下「偏好」。這裏有2個有用的鏈接:http://developer.android.com/guide/topics/data/data-storage.html和http://www.kaloer.com/android-preferences – 2011-05-17 15:52:03

0

把EditText上的值AA數據庫,文件,或SharedPreferences在它所在的活動中,並在您的小部件中讀取它。

相關問題