質問編集履歴

1

三つのクラス記載しました。

2017/01/19 14:48

投稿

sakataiyahoo
sakataiyahoo

スコア8

test CHANGED
File without changes
test CHANGED
@@ -23,3 +23,135 @@
23
23
 
24
24
 
25
25
  よろしくお願いします。
26
+
27
+ Main.java
28
+
29
+ ```
30
+
31
+ @Override
32
+
33
+ protected void onCreate(Bundle savedInstanceState) {
34
+
35
+ super.onCreate(savedInstanceState);
36
+
37
+ setContentView(R.layout.activity_main);
38
+
39
+
40
+
41
+ tweeter = (Tweeter)this.getApplication();
42
+
43
+ editLength = (EditText)findViewById(R.id.edit_length);
44
+
45
+ editPlace = (EditText)findViewById(R.id.edit_place);
46
+
47
+
48
+
49
+ Button buttonMain = (Button) findViewById(R.id.button1);
50
+
51
+ buttonMain.setOnClickListener(new View.OnClickListener() {
52
+
53
+ @Override
54
+
55
+ public void onClick(View v) {
56
+
57
+ String length = editLength.getText().toString();
58
+
59
+ tweeter.setLength(length);
60
+
61
+ String place = editPlace.getText().toString();
62
+
63
+ tweeter.setPlace(place);
64
+
65
+
66
+
67
+ Intent intent = new Intent(getApplication(), SubActivity.class);
68
+
69
+ startActivity( intent );
70
+
71
+ }
72
+
73
+ });
74
+
75
+
76
+
77
+ }
78
+
79
+ ```
80
+
81
+
82
+
83
+ Sub
84
+
85
+ ```
86
+
87
+ protected void onCreate(Bundle savedInstanceState) {
88
+
89
+ super.onCreate(savedInstanceState);
90
+
91
+ setContentView(R.layout.activity_sub);
92
+
93
+
94
+
95
+ Tweeter tweeter = (Tweeter) this.getApplication();
96
+
97
+ String str = tweeter.getTweet();
98
+
99
+
100
+
101
+ TextView textViewSub = (TextView) findViewById(R.id.tweet);
102
+
103
+ textViewSub.setText(str);
104
+
105
+
106
+
107
+ Button buttonMain = (Button) findViewById(R.id.button2);
108
+
109
+ buttonMain.setOnClickListener(new View.OnClickListener() {
110
+
111
+
112
+
113
+ @Override
114
+
115
+ public void onClick(View v) {
116
+
117
+
118
+
119
+ Intent intent = new Intent(getApplication(), ResultActivity.class);
120
+
121
+ startActivity( intent );
122
+
123
+ }
124
+
125
+ });
126
+
127
+ }
128
+
129
+ ```
130
+
131
+
132
+
133
+ result
134
+
135
+ ```
136
+
137
+ protected void onCreate(Bundle savedInstanceState) {
138
+
139
+ super.onCreate(savedInstanceState);
140
+
141
+ setContentView(R.layout.result);
142
+
143
+
144
+
145
+ Tweeter tweeter = (Tweeter) this.getApplication();
146
+
147
+ String str = tweeter.getTweet();
148
+
149
+
150
+
151
+ TextView textViewSub = (TextView) findViewById(R.id.result);
152
+
153
+ textViewSub.setText(str);
154
+
155
+ }
156
+
157
+ ```