File tree Expand file tree Collapse file tree 4 files changed +21
-22
lines changed
0302/MyAndroidTutorial/src/net/macdidi/myandroidtutorial
0303/MyAndroidTutorial/src/net/macdidi/myandroidtutorial
0304/MyAndroidTutorial/src/net/macdidi/myandroidtutorial
0401/MyAndroidTutorial/src/net/macdidi/myandroidtutorial Expand file tree Collapse file tree 4 files changed +21
-22
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,11 @@ protected void onCreate(Bundle savedInstanceState) {
4040 }
4141 else {
4242 item = new Item ();
43+ // 建立SharedPreferences物件
44+ SharedPreferences sharedPreferences = PreferenceManager .getDefaultSharedPreferences (this );
45+ // 讀取設定的預設顏色
46+ int color = sharedPreferences .getInt ("DEFAULT_COLOR" , -1 );
47+ item .setColor (getColors (color ));
4348 }
4449 }
4550
@@ -107,12 +112,6 @@ public void onSubmit(View view) {
107112 // 新增記事
108113 else {
109114 item .setDatetime (new Date ().getTime ());
110- // 建立SharedPreferences物件
111- SharedPreferences sharedPreferences =
112- PreferenceManager .getDefaultSharedPreferences (this );
113- // 讀取設定的預設顏色
114- int color = sharedPreferences .getInt ("DEFAULT_COLOR" , -1 );
115- item .setColor (getColors (color ));
116115 }
117116
118117 Intent result = getIntent ();
Original file line number Diff line number Diff line change @@ -40,6 +40,12 @@ protected void onCreate(Bundle savedInstanceState) {
4040 }
4141 else {
4242 item = new Item ();
43+ // 建立SharedPreferences物件
44+ SharedPreferences sharedPreferences =
45+ PreferenceManager .getDefaultSharedPreferences (this );
46+ // 讀取設定的預設顏色
47+ int color = sharedPreferences .getInt ("DEFAULT_COLOR" , -1 );
48+ item .setColor (getColors (color ));
4349 }
4450 }
4551
@@ -107,12 +113,6 @@ public void onSubmit(View view) {
107113 // 新增記事
108114 else {
109115 item .setDatetime (new Date ().getTime ());
110- // 建立SharedPreferences物件
111- SharedPreferences sharedPreferences =
112- PreferenceManager .getDefaultSharedPreferences (this );
113- // 讀取設定的預設顏色
114- int color = sharedPreferences .getInt ("DEFAULT_COLOR" , -1 );
115- item .setColor (getColors (color ));
116116 }
117117
118118 Intent result = getIntent ();
Original file line number Diff line number Diff line change @@ -40,6 +40,11 @@ protected void onCreate(Bundle savedInstanceState) {
4040 }
4141 else {
4242 item = new Item ();
43+ // 建立SharedPreferences物件
44+ SharedPreferences sharedPreferences = PreferenceManager .getDefaultSharedPreferences (this );
45+ // 讀取設定的預設顏色
46+ int color = sharedPreferences .getInt ("DEFAULT_COLOR" , -1 );
47+ item .setColor (getColors (color ));
4348 }
4449 }
4550
@@ -107,12 +112,6 @@ public void onSubmit(View view) {
107112 // 新增記事
108113 else {
109114 item .setDatetime (new Date ().getTime ());
110- // 建立SharedPreferences物件
111- SharedPreferences sharedPreferences =
112- PreferenceManager .getDefaultSharedPreferences (this );
113- // 讀取設定的預設顏色
114- int color = sharedPreferences .getInt ("DEFAULT_COLOR" , -1 );
115- item .setColor (getColors (color ));
116115 }
117116
118117 Intent result = getIntent ();
Original file line number Diff line number Diff line change @@ -51,6 +51,11 @@ protected void onCreate(Bundle savedInstanceState) {
5151 }
5252 else {
5353 item = new Item ();
54+ // 建立SharedPreferences物件
55+ SharedPreferences sharedPreferences = PreferenceManager .getDefaultSharedPreferences (this );
56+ // 讀取設定的預設顏色
57+ int color = sharedPreferences .getInt ("DEFAULT_COLOR" , -1 );
58+ item .setColor (getColors (color ));
5459 }
5560
5661 }
@@ -143,10 +148,6 @@ public void onSubmit(View view) {
143148 }
144149 else {
145150 item .setDatetime (new Date ().getTime ());
146- SharedPreferences sharedPreferences =
147- PreferenceManager .getDefaultSharedPreferences (this );
148- int color = sharedPreferences .getInt ("DEFAULT_COLOR" , -1 );
149- item .setColor (getColors (color ));
150151 }
151152
152153 Intent result = getIntent ();
You can’t perform that action at this time.
0 commit comments