Page 875 - 3-3
P. 875
personList = new ArrayList<HashMap<String, String>>();
// 선생님 이름에 따라 정보를 받아옴
if(name.equals(" 이두희")) {
getData("http://" + WebIP + "/project/smart-office/android/ldhinfo.php");
IF1.setText(" 이름 이두희 선생님: ");
IF2.setText(" 소속 정보통신기기과: ");
}
else if(name.equals(" 윤상종")) {
getData2("http://" + WebIP + "/project/smart-office/android/ysjinfo.php");
IF1.setText(" 이름 윤상종 선생님: ");
IF2.setText(" 소속 정보통신기기과: ");
}
else if(name.equals(" 김진섭")) {
getData3("http://" + WebIP + "/project/smart-office/android/kjsinfo.php");
IF1.setText(" 이름 김진섭 선생님: ");
IF2.setText(" 소속 정보통신기기과: ");
}
else if(name.equals(" 최윤희")) {
getData4("http://" + WebIP + "/project/smart-office/android/cyhinfo.php");
IF1.setText(" 이름 최윤희 선생님: ");
IF2.setText(" 소속 정보통신기기과: ");
}
}
// JSON 파싱
protected void showList() {
try {
JSONObject jsonObj = new JSONObject(myJSON);// JSON 생성
peoples = jsonObj.getJSONArray(TAG_JSON);// TAG_JSON 값과 일치하는 DB 값을 불러
옴
for (int i = 0; i < peoples.length(); i++) {
JSONObject c = peoples.getJSONObject(i);
String name = c.getString(TAG_Name); // TAG_Name 값을 name 에 저장
String status = c.getString(TAG_Status); // TAG_Status 값을 status 에 저장
String date = c.getString(TAG_Date); // TAG_Date 값을 date 에 저장
HashMap<String, String> persons = new HashMap<String, String>();
persons.put(TAG_Name, name); // name 값 추가
persons.put(TAG_Status, status); // status 값 추가
persons.put(TAG_Date, date); // date 값 추가
personList.add(persons); // 리스트에 추가
}
ListAdapter adapter = new SimpleAdapter(
Info_teacher.this, personList, R.layout.item_list2, // List 를 작성할 TextView 가 있는 xml 를 불러
옴
new String[]{TAG_Name, TAG_Status, TAG_Date}, // 리스트에 들어갈 내용
추가
- 875 -