Page 856 - 3-3
P. 856
e.printStackTrace();
}
}
// JSON 파싱
protected void showList2() {
try {
JSONObject jsonObj = new JSONObject(myJSON2);// JSON 생성
peoples = jsonObj.getJSONArray(TAG_JSON2); // TAG_JSON 값과 일치하는 DB 값을 불
러옴
// 상태값을 받아옴
for (int i = 0; i < 1; i++) {
JSONObject c = peoples.getJSONObject(i);
String status = c.getString(TAG_Status); // TAG_Status 값을 status 에 저장
HashMap<String, String> persons = new HashMap<String, String>();
persons.put(TAG_Status, status);
personList.add(persons); // 리스트에 추가
}
ListAdapter adapter = new SimpleAdapter(
Office_menu.this, personList, R.layout.item_list3, // List 를 작성할 TextView 가 있는 xml 를 불러
옴
new String[]{TAG_Status}, // TAG_Status 추가
new int[]{R.id.Te_info} // TextView 추가
);
list.setAdapter(adapter); // 리스트 어댑터를 불러옴
} catch (JSONException e) {
e.printStackTrace();
}
}
// JSON 파싱
protected void showList3() {
try {
JSONObject jsonObj = new JSONObject(myJSON3);// JSON 생성
peoples = jsonObj.getJSONArray(TAG_JSON3); // TAG_JSON 값과 일치하는 DB 값을 불
러옴
// 상태값을 받아옴
for (int i = 0; i < 1; i++) {
JSONObject c = peoples.getJSONObject(i);
String status = c.getString(TAG_Status); // TAG_Status 값을 status 에 저장
HashMap<String, String> persons = new HashMap<String, String>();
persons.put(TAG_Status, status); // status 값 추가
personList.add(persons); // 리스트에 추가
}
ListAdapter adapter = new SimpleAdapter(
Office_menu.this, personList, R.layout.item_list3, // List 를 작성할
TextView 가 있는 xml 를 불러옴
- 856 -