質問編集履歴
5
追記3
test
CHANGED
File without changes
|
test
CHANGED
@@ -116,7 +116,7 @@
|
|
116
116
|
|
117
117
|
|
118
118
|
|
119
|
-
**追記
|
119
|
+
**追記3**
|
120
120
|
|
121
121
|
|
122
122
|
|
@@ -144,7 +144,7 @@
|
|
144
144
|
|
145
145
|
|
146
146
|
|
147
|
-
sub.putExtra("
|
147
|
+
sub.putExtra("list_names", listView.getItemAtPosition(position).toString());
|
148
148
|
|
149
149
|
|
150
150
|
|
@@ -155,3 +155,61 @@
|
|
155
155
|
});
|
156
156
|
|
157
157
|
```
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
```ここに言語を入力
|
164
|
+
|
165
|
+
public class SubActivity extends AppCompatActivity{
|
166
|
+
|
167
|
+
@Override
|
168
|
+
|
169
|
+
public void onCreate(Bundle savedInstanceState) {
|
170
|
+
|
171
|
+
super.onCreate(savedInstanceState);
|
172
|
+
|
173
|
+
setContentView(R.layout.sub_activity);
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
TextView text = (TextView) findViewById(R.id.textView);
|
182
|
+
|
183
|
+
/*
|
184
|
+
|
185
|
+
TextView text2 = (TextView) findViewById(R.id.textView2);
|
186
|
+
|
187
|
+
TextView text3 = (TextView) findViewById(R.id.textView3);
|
188
|
+
|
189
|
+
ImageView image = (ImageView) findViewById(R.id.imageView);
|
190
|
+
|
191
|
+
*/
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
Intent sub = getIntent();
|
196
|
+
|
197
|
+
String name = sub.getStringExtra("list_names");
|
198
|
+
|
199
|
+
text.setText(name);
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
}
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
}
|
214
|
+
|
215
|
+
```
|
4
追記2
test
CHANGED
File without changes
|
test
CHANGED
@@ -126,9 +126,7 @@
|
|
126
126
|
|
127
127
|
|
128
128
|
|
129
|
-
|
130
|
-
|
131
|
-
|
129
|
+
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
132
130
|
|
133
131
|
@Override
|
134
132
|
|
@@ -146,7 +144,9 @@
|
|
146
144
|
|
147
145
|
|
148
146
|
|
149
|
-
|
147
|
+
sub.putExtra("Name", (String) listView.getItemAtPosition(position));
|
148
|
+
|
149
|
+
|
150
150
|
|
151
151
|
|
152
152
|
|
@@ -154,56 +154,4 @@
|
|
154
154
|
|
155
155
|
});
|
156
156
|
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
}
|
164
|
-
|
165
157
|
```
|
166
|
-
|
167
|
-
遷移先
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
```ここに言語を入力
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
public class SubActivity extends AppCompatActivity{
|
176
|
-
|
177
|
-
@Override
|
178
|
-
|
179
|
-
public void onCreate(Bundle savedInstanceState) {
|
180
|
-
|
181
|
-
super.onCreate(savedInstanceState);
|
182
|
-
|
183
|
-
setContentView(R.layout.sub_activity);
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
TextView text = (TextView) findViewById(R.id.textView);
|
192
|
-
|
193
|
-
text.setText(getitem);
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
}
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
}
|
208
|
-
|
209
|
-
```
|
3
追記2
test
CHANGED
File without changes
|
test
CHANGED
@@ -111,3 +111,99 @@
|
|
111
111
|
|
112
112
|
|
113
113
|
onitemclickでタップされた項目の「id」と「switchを対応させる方法」が今ひとつわからないです。
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
**追記2**
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
遷移前
|
124
|
+
|
125
|
+
```ここに言語を入力
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
132
|
+
|
133
|
+
@Override
|
134
|
+
|
135
|
+
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
Intent sub = new Intent();
|
142
|
+
|
143
|
+
sub.setClassName("com.example.tsuyoshiokaprofile", "com.example.tsuyoshiokaprofile.SubActivity");
|
144
|
+
|
145
|
+
startActivity(sub);
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
String getitem = (String)listView.getItemAtPosition(position);
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
}
|
154
|
+
|
155
|
+
});
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
}
|
164
|
+
|
165
|
+
```
|
166
|
+
|
167
|
+
遷移先
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
```ここに言語を入力
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
public class SubActivity extends AppCompatActivity{
|
176
|
+
|
177
|
+
@Override
|
178
|
+
|
179
|
+
public void onCreate(Bundle savedInstanceState) {
|
180
|
+
|
181
|
+
super.onCreate(savedInstanceState);
|
182
|
+
|
183
|
+
setContentView(R.layout.sub_activity);
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
TextView text = (TextView) findViewById(R.id.textView);
|
192
|
+
|
193
|
+
text.setText(getitem);
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
}
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
}
|
208
|
+
|
209
|
+
```
|
2
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -104,7 +104,7 @@
|
|
104
104
|
|
105
105
|
|
106
106
|
|
107
|
-
|
107
|
+
switchの引数部分にlongを入れられない、とエラーが出ています。
|
108
108
|
|
109
109
|
|
110
110
|
|
1
コード追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -25,3 +25,89 @@
|
|
25
25
|
仮にメンバー(LIstview)が100人いた場合、
|
26
26
|
|
27
27
|
「intentを100個用意する」んじゃなく、もっと簡単でスッキリさせる方法ありますか?
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
**追記部分**
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
```ここに言語を入力
|
40
|
+
|
41
|
+
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
42
|
+
|
43
|
+
@Override
|
44
|
+
|
45
|
+
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
Intent sub = new Intent();
|
52
|
+
|
53
|
+
sub.setClassName("com.example.tsuyoshiokaprofile", "com.example.tsuyoshiokaprofile.SubActivity");
|
54
|
+
|
55
|
+
startActivity(sub);
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
long get_id = id;
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
switch(get_id){
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
case 0:
|
72
|
+
|
73
|
+
text.setText(R.string.profil_name_yoshioka);
|
74
|
+
|
75
|
+
text2.setText(R.string.job_yoshioka);
|
76
|
+
|
77
|
+
text3.setText(R.string.description_yoshioka);
|
78
|
+
|
79
|
+
break;
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
}
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
}
|
96
|
+
|
97
|
+
});
|
98
|
+
|
99
|
+
```
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
switchでメンバー分の分岐を用意しようかと思うのですが、考え方はあってますでしょうか?
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
onItemClickの引数がlongでswitchにはlongを入れられない、とエラーが出ています。
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
onitemclickでタップされた項目の「id」と「switchを対応させる方法」が今ひとつわからないです。
|