質問編集履歴
1
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,59 +1,27 @@
|
|
1
1
|
intentでputExtra()とgetExtra()を使う方法を教えていただけますか?
|
2
|
-
|
3
2
|
ストリングデータを格納するストリング変数があります。activityからactivityにこのデータを送りたいです。
|
4
3
|
|
5
|
-
|
6
|
-
|
7
|
-
```lang-<ここに言語を入力>
|
8
|
-
|
9
4
|
Intent i = new Intent(ScreenA.this, ScreenB.class);
|
10
|
-
|
11
5
|
String keyID = null;
|
12
|
-
|
13
6
|
i.putExtra(str, keyIDr );
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
```
|
18
7
|
|
19
8
|
それから、
|
20
9
|
|
21
|
-
|
22
|
-
|
23
|
-
```lang-<ここに言語を入力>
|
24
|
-
|
25
10
|
SecondScreen.java:
|
26
11
|
|
12
|
+
public void onCreate(Bundle savedInstanceState)
|
13
|
+
{
|
14
|
+
super.onCreate(savedInstanceState);
|
15
|
+
setContentView(R.layout.view);
|
16
|
+
TextView usestr = (TextView)findViewById(R.id.usestr);
|
17
|
+
Bundle bundle = getIntent().getExtras();
|
27
18
|
|
28
|
-
|
29
|
-
|
19
|
+
if(bundle.getString("str")!= null)
|
30
|
-
|
31
20
|
{
|
32
|
-
|
33
|
-
super.onCreate(savedInstanceState);
|
34
|
-
|
35
|
-
setContentView(R.layout.view);
|
36
|
-
|
37
|
-
TextView usestr = (TextView)findViewById(R.id.usestr);
|
38
|
-
|
39
|
-
Bundle bundle = getIntent().getExtras();
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
if(bundle.getString("str")!= null)
|
44
|
-
|
45
|
-
{
|
46
|
-
|
47
|
-
|
21
|
+
//ストリング変数に格納されたストリングを取得し、
|
48
|
-
|
49
|
-
|
22
|
+
// userNameでsetText()を行います
|
50
|
-
|
51
|
-
|
23
|
+
}
|
52
|
-
|
53
|
-
|
54
24
|
|
55
25
|
}
|
56
26
|
|
57
|
-
```
|
58
|
-
|
59
27
|
基礎的な質問なのですが、お助け願います
|