質問編集履歴
1
改善ソースの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -183,3 +183,175 @@
|
|
183
183
|
|
184
184
|
|
185
185
|
よろしくお願いします
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
//-------追記---------//
|
190
|
+
|
191
|
+
```java
|
192
|
+
|
193
|
+
public Object instantiateItem(View collection, final int position) {
|
194
|
+
|
195
|
+
llv = new LinearLayout(mContext);
|
196
|
+
|
197
|
+
llv.setOrientation(LinearLayout.VERTICAL);
|
198
|
+
|
199
|
+
gl = (Globals) mContext.getApplicationContext();
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
new Thread(new Runnable(){
|
204
|
+
|
205
|
+
@Override
|
206
|
+
|
207
|
+
public void run(){
|
208
|
+
|
209
|
+
try{
|
210
|
+
|
211
|
+
URL url = new URL("http://153.149.37.82/Eigyo_Test/xml/detail.php?position=" + position + "&search="+ gl.ProspectId +"&comcode=" + gl.ComCode + "&logid=" + gl.tID );
|
212
|
+
|
213
|
+
Log.d("URL1212",url.toString());
|
214
|
+
|
215
|
+
HttpURLConnection con = (HttpURLConnection)url.openConnection();
|
216
|
+
|
217
|
+
String str = InputStreamToString(con.getInputStream());
|
218
|
+
|
219
|
+
Log.d("xml",str);
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
while(str !=null){
|
224
|
+
|
225
|
+
//xmlparse開始
|
226
|
+
|
227
|
+
XmlPullParser xpp = Xml.newPullParser();
|
228
|
+
|
229
|
+
try{
|
230
|
+
|
231
|
+
xpp.setInput(new StringReader(str));
|
232
|
+
|
233
|
+
}catch (XmlPullParserException e){
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
}
|
238
|
+
|
239
|
+
// XML解析
|
240
|
+
|
241
|
+
try {
|
242
|
+
|
243
|
+
int eventType;
|
244
|
+
|
245
|
+
eventType = xpp.getEventType();
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
final LinearLayout llh = new LinearLayout(mContext);
|
250
|
+
|
251
|
+
llh.setOrientation(LinearLayout.HORIZONTAL);
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
while (eventType != xpp.END_DOCUMENT) {
|
256
|
+
|
257
|
+
if((eventType == xpp.START_TAG)){
|
258
|
+
|
259
|
+
if(("DateTitle"+position).equals(xpp.getName())){
|
260
|
+
|
261
|
+
// llv = new LinearLayout(mContext);
|
262
|
+
|
263
|
+
// llv.setOrientation(LinearLayout.VERTICAL);
|
264
|
+
|
265
|
+
final TextView tv = new TextView(mContext);
|
266
|
+
|
267
|
+
final String txt = xpp.nextText();
|
268
|
+
|
269
|
+
handler.post(new Runnable() {
|
270
|
+
|
271
|
+
@Override
|
272
|
+
|
273
|
+
public void run() {
|
274
|
+
|
275
|
+
tv.setTextSize(12);
|
276
|
+
|
277
|
+
tv.setBackgroundColor(Color.parseColor("#d3d3d3"));
|
278
|
+
|
279
|
+
tv.setText(txt);
|
280
|
+
|
281
|
+
llh.addView(tv);
|
282
|
+
|
283
|
+
}
|
284
|
+
|
285
|
+
});
|
286
|
+
|
287
|
+
}else if(("DateData"+position).equals(xpp.getName())){
|
288
|
+
|
289
|
+
final TextView tv = new TextView(mContext);
|
290
|
+
|
291
|
+
final String txt = xpp.nextText();
|
292
|
+
|
293
|
+
handler.post(new Runnable() {
|
294
|
+
|
295
|
+
@Override
|
296
|
+
|
297
|
+
public void run() {
|
298
|
+
|
299
|
+
tv.setTextSize(18);
|
300
|
+
|
301
|
+
tv.setText(txt);
|
302
|
+
|
303
|
+
llh.addView(tv);
|
304
|
+
|
305
|
+
llv.addView(llh);
|
306
|
+
|
307
|
+
}
|
308
|
+
|
309
|
+
});
|
310
|
+
|
311
|
+
}
|
312
|
+
|
313
|
+
}
|
314
|
+
|
315
|
+
|
316
|
+
|
317
|
+
eventType = xpp.next();
|
318
|
+
|
319
|
+
}
|
320
|
+
|
321
|
+
}catch (Exception e){
|
322
|
+
|
323
|
+
Log.d("XmlPullParser", String.valueOf(e));
|
324
|
+
|
325
|
+
}
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
llv.postInvalidate();
|
330
|
+
|
331
|
+
|
332
|
+
|
333
|
+
break;
|
334
|
+
|
335
|
+
}
|
336
|
+
|
337
|
+
|
338
|
+
|
339
|
+
}catch (Exception ex){
|
340
|
+
|
341
|
+
System.out.println(ex);
|
342
|
+
|
343
|
+
}
|
344
|
+
|
345
|
+
}
|
346
|
+
|
347
|
+
}).start();
|
348
|
+
|
349
|
+
|
350
|
+
|
351
|
+
((ViewPager) collection).addView(llv,0);
|
352
|
+
|
353
|
+
return llv;
|
354
|
+
|
355
|
+
}
|
356
|
+
|
357
|
+
```
|