質問編集履歴
2
タイトル変更
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
【Android】リストアイテム内ラジオボタンの実装バグ
|
1
|
+
【Android】ListViewのリストアイテム内ラジオボタンの実装バグ
|
test
CHANGED
File without changes
|
1
誤記の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Android Javaにてアプリ作成をしております。
|
4
4
|
|
5
|
-
|
5
|
+
ラジオボタンがリストアイテム内にあるリストがあり、そちらのバグが解消できずにいます。
|
6
6
|
|
7
7
|
どうかご教示頂きたく存じております。
|
8
8
|
|
@@ -32,20 +32,206 @@
|
|
32
32
|
|
33
33
|
###実装内容
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
35
|
+
Xml部
|
36
|
+
|
37
|
+
```
|
38
|
+
|
39
|
+
<RelativeLayout xmlns:tools="http://schemas.android.com/tools"
|
40
|
+
|
41
|
+
android:orientation="vertical"
|
42
|
+
|
43
|
+
android:layout_width="match_parent"
|
44
|
+
|
45
|
+
android:layout_height="match_parent"
|
46
|
+
|
47
|
+
xmlns:android="http://schemas.android.com/apk/res/android"
|
48
|
+
|
49
|
+
xmlns:app="http://schemas.android.com/apk/res-auto">
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
<RelativeLayout
|
54
|
+
|
55
|
+
android:layout_width="match_parent"
|
56
|
+
|
57
|
+
android:layout_height="wrap_content">
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
<CheckBox
|
62
|
+
|
63
|
+
android:id="@+id/checkBox"
|
64
|
+
|
65
|
+
android:layout_width="wrap_content"
|
66
|
+
|
67
|
+
android:layout_height="50dp"
|
68
|
+
|
69
|
+
android:layout_alignParentTop="true"
|
70
|
+
|
71
|
+
android:layout_alignParentLeft="true" />
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
<RelativeLayout
|
76
|
+
|
77
|
+
android:layout_width="match_parent"
|
78
|
+
|
79
|
+
android:layout_height="50dp"
|
80
|
+
|
81
|
+
android:id="@+id/title_area"
|
82
|
+
|
83
|
+
android:layout_alignParentTop="true"
|
84
|
+
|
85
|
+
android:layout_toRightOf="@+id/checkBox">
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
<TextView
|
90
|
+
|
91
|
+
android:layout_width="wrap_content"
|
92
|
+
|
93
|
+
android:layout_height="wrap_content"
|
94
|
+
|
95
|
+
android:textAppearance="?android:attr/textAppearanceLarge"
|
96
|
+
|
97
|
+
android:text="name"
|
98
|
+
|
99
|
+
android:id="@+id/display_name"
|
100
|
+
|
101
|
+
android:layout_centerVertical="true"
|
102
|
+
|
103
|
+
android:layout_alignParentLeft="true" />
|
104
|
+
|
105
|
+
</RelativeLayout>
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
<RelativeLayout
|
110
|
+
|
111
|
+
android:layout_width="wrap_content"
|
112
|
+
|
113
|
+
android:layout_height="wrap_content"
|
114
|
+
|
115
|
+
android:id="@+id/item_area"
|
116
|
+
|
117
|
+
android:layout_below="@+id/title_area"
|
118
|
+
|
119
|
+
android:layout_toRightOf="@+id/checkBox"
|
120
|
+
|
121
|
+
android:orientation="horizontal">
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
<TextView
|
126
|
+
|
127
|
+
android:id="@+id/radio_text"
|
128
|
+
|
129
|
+
android:layout_width="wrap_content"
|
130
|
+
|
131
|
+
android:layout_height="wrap_content"
|
132
|
+
|
133
|
+
android:layout_alignParentLeft="true"
|
134
|
+
|
135
|
+
android:text="ラジオ"
|
136
|
+
|
137
|
+
android:textAppearance="?android:attr/textAppearanceMedium" />
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
<RadioGroup
|
142
|
+
|
143
|
+
android:id="@+id/radio"
|
144
|
+
|
145
|
+
android:layout_width="wrap_content"
|
146
|
+
|
147
|
+
android:layout_height="wrap_content"
|
148
|
+
|
149
|
+
android:layout_below="@+id/radio_text" />
|
150
|
+
|
151
|
+
</RelativeLayout>
|
152
|
+
|
153
|
+
</RelativeLayout>
|
154
|
+
|
155
|
+
</RelativeLayout>
|
156
|
+
|
157
|
+
```
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
Java部
|
162
|
+
|
163
|
+
```
|
164
|
+
|
165
|
+
public class CustomAdapter extends BaseAdapter{
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
~~ 省略 ~~
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
@Override
|
174
|
+
|
175
|
+
public View getView(final int position, View convertView, final ViewGroup parent) {
|
176
|
+
|
177
|
+
Data data = (Data)getItem(position);
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
final int WC = ViewGroup.LayoutParams.WRAP_CONTENT;
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
viewHolder.radioRadio.removeAllViews();
|
186
|
+
|
187
|
+
RadioGroup radioGroup = data.getRadioGroup();
|
188
|
+
|
189
|
+
if(radioGroup != null) {
|
190
|
+
|
191
|
+
viewHolder.radio = radioGroup;
|
192
|
+
|
193
|
+
} else {
|
194
|
+
|
195
|
+
ArrayList<String> radioDatas = data.getRadioDatas();
|
196
|
+
|
197
|
+
if (radioDatas != null) {
|
198
|
+
|
199
|
+
for (int i = 0; i < radioDatas.size(); i++) {
|
200
|
+
|
201
|
+
RadioButton radioButton = new RadioButton(context);
|
202
|
+
|
203
|
+
String radioData = radioDatas.get(i);
|
204
|
+
|
205
|
+
radioButton.setText(radioData);
|
206
|
+
|
207
|
+
String id = String.valueOf((position * 100) + i);
|
208
|
+
|
209
|
+
radioButton.setId(Integer.parseInt(id));
|
210
|
+
|
211
|
+
radioButton.setTag(Integer.parseInt(id));
|
212
|
+
|
213
|
+
viewHolder.radioGroup.addView(radioButton , new ViewGroup.LayoutParams(WC , WC));
|
214
|
+
|
215
|
+
}
|
216
|
+
|
217
|
+
}
|
218
|
+
|
219
|
+
dataList.get(position).setRadioDatas(viewHolder.radio);
|
220
|
+
|
221
|
+
}
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
return convertView;
|
226
|
+
|
227
|
+
}
|
228
|
+
|
229
|
+
}
|
230
|
+
|
231
|
+
```
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
###備考欄
|
236
|
+
|
237
|
+
事情によりcompileSdkVersionが15となっています
|