質問編集履歴
1
コードの追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -4,4 +4,29 @@
|
|
4
4
|
|
5
5
|
しかし何度か遷移させてみたところgetIntent()をして受け取った値は更新されず、TextViewには初めに受け取った値しか表示されません。
|
6
6
|
|
7
|
-
どうすれば想定した通りの動作をしてくれるか分からず調べたところonNewIntenT()やIntent.FLAG_ACTIVITY_NEW_TASKといった言葉が出てきましたが意味もよくわからず…これ以外でも構わないので、受け取るintentの値を更新する方法をどなたか教えてくださいm(;__)m
|
7
|
+
どうすれば想定した通りの動作をしてくれるか分からず調べたところonNewIntenT()やIntent.FLAG_ACTIVITY_NEW_TASKといった言葉が出てきましたが意味もよくわからず…これ以外でも構わないので、受け取るintentの値を更新する方法をどなたか教えてくださいm(;__)m
|
8
|
+
|
9
|
+
(追記)
|
10
|
+
|
11
|
+
|
12
|
+
final Button toTopButton = (Button)findViewById(R.id.toTopList);
|
13
|
+
toTopButton.setOnClickListener(new View.OnClickListener() {
|
14
|
+
@Override
|
15
|
+
public void onClick(View v) {
|
16
|
+
Intent toTopIntent = new Intent(ListActivity.this,MainActivity.class);
|
17
|
+
TextView item = (TextView)findViewById(R.id.listTime);
|
18
|
+
toTopIntent.putExtra("todayTop",item.getText().toString());
|
19
|
+
startActivity(toTopIntent);
|
20
|
+
}
|
21
|
+
});
|
22
|
+
これが遷移元のアクティビティで、別アクティビティのEditTextに入力された値をintentで受け取ってTextViewへ表示し、そのTextViewから値を取得して遷移先アクティビティへintentを使って渡しています。
|
23
|
+
|
24
|
+
|
25
|
+
regData = intent.getStringExtra("todayTop");
|
26
|
+
|
27
|
+
TextView textView = (TextView)findViewById(R.id.text);
|
28
|
+
|
29
|
+
if(regData != null){
|
30
|
+
textView.setText(regData);
|
31
|
+
}
|
32
|
+
こちらが遷移先アクティビティです。
|