안녕하세요 초보 개발자 입니다..
커스텀 어뎁터 안에서 버튼 클릭시(삭제버튼) 새로고침이 되도록 하고 싶은데
어뎁터 안에서는 notifydataSetChanged();가 먹히지 않나요?? 어떻해 방법이 없을지...삭제는되는데 새로고침이 안되서
좀 도와주세요.
public class Schedule_List_Adapter extends ArrayAdapter<Schedule_List_Data> implements OnClickListener {
private ArrayList<Schedule_List_Data> items;
Context context;
public Schedule_List_Adapter(Context context, int textViewResourceId, ArrayList<Schedule_List_Data> items) {
super(context, textViewResourceId, items);
this.context = context;
this.items = items;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
// TODO Auto-generated method stub
if (v == null) {
LayoutInflater vi = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.schedule_list, null);
}
Schedule_List_Data schedule_List_Data = items.get(position);
if (schedule_List_Data != null) {
TextView tv_schedule_title = (TextView) v.findViewById(R.id.tv_schedule_title);
ImageButton ib_schedule_delete = (ImageButton) v.findViewById(R.id.ib_schedule_delete);
ib_schedule_delete.setTag(position);
ib_schedule_delete.setOnClickListener(Schedule_List_Adapter.this);
tv_schedule_title.setText(schedule_List_Data.getTitle());
ib_schedule_delete.setBackgroundDrawable(schedule_List_Data.getImage_delete());
ib_schedule_delete.setTag(position); // 수정,삭제에 활용
ib_schedule_delete.setFocusable(false);
}
return v;
}
public void onClick(View v) {
App.select_schedule_idx = (Integer) v.getTag();
(new Schedule_DeleteTask()).execute(null, null, null);
}
private class Schedule_DeleteTask extends AsyncTask<Context, Integer, Integer> {
private ProgressDialog progressDialog;
int intRes;
JSONArray jArray;
public Schedule_DeleteTask() {
intRes = 3;
jArray = null;
}
protected void onPreExecute() {
super.onPreExecute();
progressDialog = new ProgressDialog(context);
progressDialog.setMessage("잠시만기다려주세요");
progressDialog.setIndeterminate(true);
progressDialog.setCancelable(true);
progressDialog.show();
}
protected void onProgressUpdate(Integer... values) {
super.onProgressUpdate(values);
}
protected void onCancelled() {
super.onCancelled();
}
protected Integer doInBackground(Context... params) {
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("svccode", App.svccode));
nameValuePairs.add(new BasicNameValuePair("regdate", App.select_date));
nameValuePairs.add(new BasicNameValuePair("class_idx", App.user_class_idx));
nameValuePairs.add(new BasicNameValuePair("sch_idx", App.select_day_schedule_idx[App.select_schedule_idx]));
jArray = Util.callAsp("ScheduleDelete.asp", nameValuePairs);
return intRes;
}
// doInBackground 후 싱행
protected void onPostExecute(Integer result) {
super.onPostExecute(result);
try {
if (jArray == null) {
Util.showShortToast(context, "서버와의 통신을 실패하였습니다.\n네트워크 설정을 확인하시고 잠시후에 다시 시도하십시오.");
} else {
JSONObject jso = jArray.getJSONObject(0);
final int return_code = jso.getInt("return_code");
if (return_code == 1) {
Util.showShortToast(context, "삭제완료");
} else if (return_code == -1) {
Util.showShortToast(context, "서비스 코드 존재하지 않음");
} else if (return_code == -2) {
Toast.makeText(context, "어린이집 전체 일정은 삭제할 수 없습니다", 4000).show();
} else if (return_code == -99) {
Util.showShortToast(context, "코드이상");
}
}
} catch (Exception e) {
e.printStackTrace();
}
finally {
progressDialog.dismiss();
progressDialog = null;
notifydataSetChanged(); // 왜 안먹힐까요...
}
}
}
}
class Schedule_List_Data {
private String title;
private Drawable Image_delete;
public Schedule_List_Data(String _title, Drawable _Image_delete) {
this.title = _title;
this.Image_delete = _Image_delete;
}
public void setTitle(String title) {
this.title = title;
}
public String getTitle() {
return title;
}
public void setImage_delete(Drawable image_delete) {
Image_delete = image_delete;
}
public Drawable getImage_delete() {
return Image_delete;
}
}




Schedule_List_Adapter.this.notifydataSetChanged();
해보세요