탭호스트를 사용해서 해당되는 탭에 php를 호출하려고합니다.
탭을누르면 url이 DownloadJSONFileAsync 클래스에 전달이 안됩니다ㅜㅜ도와주세요.
tabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() {
@Override
public void onTabChanged(String tabId) {
if(tabId.equalsIgnoreCase("Tab1")) {
MyArrList.clear();
getJSONUrl("http://웹서버/getGallery.php");
}else if(tabId.equalsIgnoreCase("Tab2")){
MyArrList.clear();
getJSONUrl("http://웹서버/getGallery.php");
}else if(tabId.equalsIgnoreCase("Tab3")){
MyArrList.clear();
getJSONUrl("http://웹서버/getGallery.php");
}else if(tabId.equalsIgnoreCase("Tab4")){
MyArrList.clear();
getJSONUrl("http://웹서버/getGallery.php");
}
}
});
class DownloadJSONFileAsync extends AsyncTask<String, Void, Void> {
protected void onPreExecute() {
super.onPreExecute();
showDialog(DIALOG_DOWNLOAD_JSON_PROGRESS);
}
@Override
protected Void doInBackground(String... params) {
// TODO Auto-generated method stub
String url = "http://웹서버/getGallery.php";
JSONArray data;
try {
data = new JSONArray(getJSONUrl(url));
MyArrList = new ArrayList<HashMap<String, Object>>();
HashMap<String, Object> map;
for (int i = 0; i < data.length(); i++) {
JSONObject c = data.getJSONObject(i);
map = new HashMap<String, Object>();
map.put("Name", (String) c.getString("Name"));
map.put("ImageName", (String) c.getString("ImageName"));
// Thumbnail Get ImageBitmap To Object
map.put("ImagePathThum", (String) c.getString("ImagePath_Thumbnail"));
map.put("ImageThumBitmap", (Bitmap) loadBitmap(c.getString("ImagePath_Thumbnail")));
// Full (for View Popup)
map.put("ImagePathFull", (String) c.getString("ImagePath_FullPhoto"));
MyArrList.add(map);
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
protected void onPostExecute(Void unused) {
ShowAllContent(); // When Finish Show Content
dismissDialog(DIALOG_DOWNLOAD_JSON_PROGRESS);
removeDialog(DIALOG_DOWNLOAD_JSON_PROGRESS);
}
}