質問編集履歴

1

変更後を追加

2017/03/10 05:31

投稿

hiziki
hiziki

スコア54

test CHANGED
File without changes
test CHANGED
@@ -144,6 +144,130 @@
144
144
 
145
145
 
146
146
 
147
+ ###解決後
148
+
149
+ fragment_main.xml
150
+
151
+ ```xml
152
+
153
+ <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
154
+
155
+ xmlns:app="http://schemas.android.com/apk/res-auto"
156
+
157
+ xmlns:tools="http://schemas.android.com/tools"
158
+
159
+ android:layout_width="match_parent"
160
+
161
+ android:layout_height="match_parent">
162
+
163
+ <LinearLayout
164
+
165
+ android:layout_width="match_parent"
166
+
167
+ android:layout_height="wrap_content"
168
+
169
+ android:orientation="horizontal">
170
+
171
+
172
+
173
+ <RadioGroup
174
+
175
+ android:id="@+id/RadioGroup"
176
+
177
+ android:layout_width="match_parent"
178
+
179
+ android:layout_height="wrap_content">
180
+
181
+
182
+
183
+ <RadioButton
184
+
185
+ android:id="@+id/rbtn_test"
186
+
187
+ android:layout_width="match_parent"
188
+
189
+ android:layout_height="wrap_content"
190
+
191
+ android:text="あいうえお"></RadioButton>
192
+
193
+
194
+
195
+ <RadioButton
196
+
197
+ android:id="@+id/rbtn_other"
198
+
199
+ android:layout_width="match_parent"
200
+
201
+ android:layout_height="wrap_content"
202
+
203
+ android:text="その他(入力してください)"></RadioButton>
204
+
205
+
206
+
207
+ <EditText
208
+
209
+ android:id="@+id/txt_other"
210
+
211
+ android:layout_width="fill_parent"
212
+
213
+ android:layout_height="wrap_content"
214
+
215
+ android:visibility="gone"
216
+
217
+ android:inputType="text" />
218
+
219
+ </RadioGroup>
220
+
221
+ </LinearLayout>
222
+
223
+ </FrameLayout>
224
+
225
+ ```
226
+
227
+ main.java
228
+
229
+ ```Java
230
+
231
+ @Override
232
+
233
+ public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
234
+
235
+ final View v = inflater.inflate(R.layout.fragment_upload,container, false);
236
+
237
+
238
+
239
+ rbtn_other = (RadioButton) v.findViewById(R.id.rbtn_other);
240
+
241
+
242
+
243
+ rbtn_other.setOnClickListener(new View.OnClickListener() {
244
+
245
+ @Override
246
+
247
+ public void onClick(View v) {
248
+
249
+ EditText txt_other = (EditText)getActivity().findViewById(R.id.txt_other);
250
+
251
+ if (txt_other.getVisibility() != View.VISIBLE){
252
+
253
+ txt_other.setVisibility(View.VISIBLE);
254
+
255
+ }else {
256
+
257
+ txt_other.setVisibility(View.INVISIBLE);
258
+
259
+ }
260
+
261
+ }
262
+
263
+ });
264
+
265
+ return v;
266
+
267
+ ```
268
+
269
+
270
+
147
271
  ###試したこと
148
272
 
149
273