質問編集履歴

1

ソースコードの貼付け場所を間違えていたので修正しました。

2015/12/09 03:54

投稿

SumioShimizu
SumioShimizu

スコア16

test CHANGED
File without changes
test CHANGED
@@ -2,228 +2,270 @@
2
2
 
3
3
  登録したListenerからの割込みでこの処理が実行されるのは確認しています。
4
4
 
5
+ ```ここに言語を入力
6
+
7
+ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++MainActivity.javaの内容
8
+
9
+ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//テーブル行の動的追加処理
10
+
11
+ 省略
12
+
13
+ final TableLayout tableLayout = (TableLayout) findViewById(R.id.tableLayout);
14
+
15
+ 省略
16
+
17
+ //全行削除
18
+
19
+ tableLayout.removeAllViews();
20
+
21
+ //タイトル表示
22
+
23
+ final TableRow tableRow0 = (TableRow) getLayoutInflater().inflate(R.layout.table_row0, null);
24
+
25
+ tableLayout.addView(tableRow0, new TableLayout.LayoutParams(MP, WC));
26
+
27
+ 省略
28
+
29
+ //明細行表示
30
+
31
+ for (int ii = 0; ii < categoryNum; ii++) {
32
+
33
+ 省略
34
+
35
+ // ボタン機能追加.
36
+
37
+ TextView radio = (Button)tableRow.findViewById(R.id.rowradioButton);
38
+
39
+ radio.setText("a");
40
+
41
+
42
+
43
+ TextView checkBox = (CheckBox)tableRow.findViewById(R.id.rowcheckBox);
44
+
45
+ checkBox.setText("b");
46
+
47
+
48
+
49
+ (tableRow.findViewById(R.id.rowradioButton)).setOnClickListener(new View.OnClickListener() {
50
+
51
+ @Override
52
+
53
+ public void onClick(View v) {
54
+
55
+
56
+
57
+ **//ボタンを押下した行数の求め方がわからない!!
58
+
59
+ //Listenerからの割込みでこの処理は実行されるのですが、何行目(ii)のボタンが押下されたかを取得する関数がわかりません。
60
+
61
+ **
62
+
63
+ }
64
+
65
+ });
66
+
67
+ 省略
68
+
69
+ tableLayout.addView(tableRow, new TableLayout.LayoutParams(MP, WC));
70
+
71
+ }
72
+
73
+ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
74
+
75
+ activity_main.xmlの内容
76
+
77
+ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<?xml version="1.0" encoding="utf-8"?>
78
+
79
+ 省略
80
+
81
+ <!--タイトル表示-->
82
+
83
+ <TableLayout
84
+
85
+ android:id="@+id/tableLayout"
86
+
87
+ android:layout_width="match_parent"
88
+
89
+ android:layout_height="wrap_content"
90
+
91
+ android:stretchColumns="0" >
92
+
93
+ </TableLayout>
94
+
95
+ 省略
96
+
97
+ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
98
+
99
+ table_row0.xmlの内容
100
+
101
+ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<?xml version="1.0" encoding="utf-8"?>
102
+
103
+ <!--動的タイトル追加-->
104
+
105
+ <TableRow xmlns:android="http://schemas.android.com/apk/res/android"
106
+
107
+ android:id="@+id/tableRow1"
108
+
109
+ android:layout_width="match_parent"
110
+
111
+ android:layout_height="wrap_content"
112
+
113
+ android:layout_marginBottom="5dp" >
114
+
115
+
116
+
117
+ 省略
118
+
119
+
120
+
121
+ <Button
122
+
123
+ style="?android:attr/buttonStyleSmall"
124
+
125
+ android:layout_width="wrap_content"
126
+
127
+ android:layout_height="wrap_content"
128
+
129
+ android:layout_alignTop="@id/textView4"
130
+
131
+ android:id="@+id/button4"
132
+
133
+ android:textSize="8dp"
134
+
135
+ android:text="修正" />
136
+
137
+ <Button
138
+
139
+ style="?android:attr/buttonStyleSmall"
140
+
141
+ android:layout_width="wrap_content"
142
+
143
+ android:layout_height="wrap_content"
144
+
145
+ android:layout_alignTop="@id/button4"
146
+
147
+ android:id="@+id/button5"
148
+
149
+ android:textSize="8dp"
150
+
151
+ android:text="削除" />
152
+
153
+
154
+
155
+ </TableRow>
156
+
157
+ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
158
+
159
+ table_row.xml
160
+
5
161
  ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6
162
 
7
-
8
-
9
- MainActivity.javaの内容
10
-
11
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
12
-
13
- //テーブル行の動的追加処理
14
-
15
- 省略
16
-
17
- final TableLayout tableLayout = (TableLayout) findViewById(R.id.tableLayout);
18
-
19
- 省略
20
-
21
- //全行削除
22
-
23
- tableLayout.removeAllViews();
24
-
25
- //タイトル表示
26
-
27
- final TableRow tableRow0 = (TableRow) getLayoutInflater().inflate(R.layout.table_row0, null);
28
-
29
- tableLayout.addView(tableRow0, new TableLayout.LayoutParams(MP, WC));
30
-
31
- 省略
32
-
33
- //明細行表示
34
-
35
- for (int ii = 0; ii < categoryNum; ii++) {
36
-
37
- 省略
38
-
39
- // ボタン機能追加.
40
-
41
- TextView radio = (Button)tableRow.findViewById(R.id.rowradioButton);
42
-
43
- radio.setText("a");
44
-
45
-
46
-
47
- TextView checkBox = (CheckBox)tableRow.findViewById(R.id.rowcheckBox);
48
-
49
- checkBox.setText("b");
50
-
51
-
52
-
53
- (tableRow.findViewById(R.id.rowradioButton)).setOnClickListener(new View.OnClickListener() {
54
-
55
- @Override
56
-
57
- public void onClick(View v) {
58
-
59
-
60
-
61
- **//ボタンを押下した行数の求め方がわからない!!
62
-
63
- //Listenerからの割込みでこの処理は実行されるのですが、何行目(ii)のボタンが押下されたかを取得する関数がわかりません。
64
-
65
- **
66
-
67
- }
68
-
69
- });
70
-
71
- 省略
72
-
73
- tableLayout.addView(tableRow, new TableLayout.LayoutParams(MP, WC));
74
-
75
- }
76
-
77
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
78
-
79
-
80
-
81
- activity_main.xmlの内容
82
-
83
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
84
-
85
163
  <?xml version="1.0" encoding="utf-8"?>
86
164
 
87
- 省略
88
-
89
- <!--タイトル表示-->
90
-
91
- <TableLayout
92
-
93
- android:id="@+id/tableLayout"
94
-
95
- android:layout_width="match_parent"
96
-
97
- android:layout_height="wrap_content"
98
-
99
- android:stretchColumns="0" >
100
-
101
- </TableLayout>
102
-
103
- 省略
104
-
105
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
106
-
107
-
108
-
109
- table_row0.xmlの内容
110
-
111
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
112
-
113
- <?xml version="1.0" encoding="utf-8"?>
114
-
115
- <!--動的タイトル追加-->
165
+ <!--動的明細行追加-->
116
166
 
117
167
  <TableRow xmlns:android="http://schemas.android.com/apk/res/android"
118
168
 
119
- android:id="@+id/tableRow1"
169
+ android:id="@+id/tableRow0"
120
170
 
121
171
  android:layout_width="match_parent"
122
172
 
123
- android:layout_height="wrap_content"
173
+ android:layout_height="match_parent"
124
-
174
+
125
- android:layout_marginBottom="5dp" >
175
+ android:background="@color/ColorLTGRAY" >
126
-
127
-
128
-
176
+
177
+
178
+
129
- 省略
179
+ 省略
130
-
131
-
132
-
180
+
181
+
182
+
133
- <Button
183
+ <RadioButton
134
-
135
- style="?android:attr/buttonStyleSmall"
136
184
 
137
185
  android:layout_width="wrap_content"
138
186
 
139
187
  android:layout_height="wrap_content"
140
188
 
189
+ android:layout_marginLeft="1dp"
190
+
141
- android:layout_alignTop="@id/textView4"
191
+ android:background="@color/ColorWHITE"
192
+
142
-
193
+ android:gravity="center"
194
+
143
- android:id="@+id/button4"
195
+ android:id="@+id/rowradioButton"
144
-
145
- android:textSize="8dp"
196
+
146
-
147
- android:text="修正" />
197
+ android:checked="false" />
148
-
198
+
149
- <Button
199
+ <CheckBox
150
-
151
- style="?android:attr/buttonStyleSmall"
200
+
152
-
153
- android:layout_width="wrap_content"
201
+ android:layout_width="wrap_content"
154
-
202
+
155
- android:layout_height="wrap_content"
203
+ android:layout_height="wrap_content"
156
-
204
+
157
- android:layout_alignTop="@id/button4"
205
+ android:layout_marginLeft="1dp"
158
-
206
+
159
- android:id="@+id/button5"
207
+ android:background="@color/ColorWHITE"
160
-
208
+
161
- android:textSize="8dp"
209
+ android:gravity="center"
162
-
210
+
163
- android:text="削除" />
211
+ android:id="@+id/rowcheckBox"/>
164
212
 
165
213
 
166
214
 
167
215
  </TableRow>
168
216
 
169
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
170
-
171
-
172
-
173
- table_row.xml
174
-
175
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
176
-
177
- <?xml version="1.0" encoding="utf-8"?>
178
-
179
- <!--動的明細行追加-->
180
-
181
- <TableRow xmlns:android="http://schemas.android.com/apk/res/android"
182
-
183
- android:id="@+id/tableRow0"
184
-
185
- android:layout_width="match_parent"
186
-
187
- android:layout_height="match_parent"
188
-
189
- android:background="@color/ColorLTGRAY" >
190
-
191
-
192
-
193
- 省略
194
-
195
-
196
-
197
- <RadioButton
198
-
199
- android:layout_width="wrap_content"
200
-
201
- android:layout_height="wrap_content"
202
-
203
- android:layout_marginLeft="1dp"
204
-
205
- android:background="@color/ColorWHITE"
206
-
207
- android:gravity="center"
208
-
209
- android:id="@+id/rowradioButton"
210
-
211
- android:checked="false" />
212
-
213
- <CheckBox
214
-
215
- android:layout_width="wrap_content"
216
-
217
- android:layout_height="wrap_content"
218
-
219
- android:layout_marginLeft="1dp"
220
-
221
- android:background="@color/ColorWHITE"
222
-
223
- android:gravity="center"
224
-
225
- android:id="@+id/rowcheckBox"/>
226
-
227
-
228
-
229
- </TableRow>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
217
+ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
218
+
219
+ 前提・実現したいこと
220
+
221
+ ボタン押下のイベントが動的に追加した何行目のボタンかを取得したい。
222
+
223
+ ###発生している問題・エラーメッセージ
224
+
225
+
226
+
227
+ ###ソースコード
228
+
229
+ ```ここに言語を入力
230
+
231
+ ###補足情報(言語/FW/ツール等のバージョンなど)`````````ここに言語を入力
232
+
233
+ ここに言語を入力
234
+
235
+ ```
236
+
237
+ ここに言語を入力
238
+
239
+ ```
240
+
241
+ コード
242
+
243
+ ```
244
+
245
+ ###前提・実現したいこと
246
+
247
+ (例)PHP(CakePHP)で●●なシステムを作っています。
248
+
249
+ ■■な機能を実装したいのですがうまく動きません。
250
+
251
+
252
+
253
+ ###発生している問題・エラーメッセージ
254
+
255
+
256
+
257
+ ###ソースコード
258
+
259
+ ```ここに言語を入力
260
+
261
+ ここにご自身が実行したソースコードを書いてください
262
+
263
+ ```
264
+
265
+
266
+
267
+ ###補足情報(言語/FW/ツール等のバージョンなど)```- ここに言語を入力
268
+
269
+ コード
270
+
271
+ ``````