이것은 listview 데이터를 버튼 클럭 asyn 작업에 대한 서버 ans sqlite에 보내는 목록보기 어댑터입니다. 진행 대화 상자를 사용하고 싶지만 진행 상황 대화 상자에서 활동 인스턴스와 코드 충돌이 발생하는 동안 문제가 발생합니다.기본 어댑터의 진행 대화 상자 설정
public class PlannningListViewAdapter extends BaseAdapter{
Context context;
public ArrayList<Planning> planArraylist;
private static LayoutInflater inflater = null;
public PlanningList_activity planActivity;
public ListView mListview;
Db_sqlite databaseHelper;
Calendar calObj = Calendar.getInstance();
DateFormat cdf = new SimpleDateFormat("MM-dd-yyyy hh:mm:ss a");
String currentDate = cdf.format(calObj.getTime()).toString();
public PlannningListViewAdapter(Context context,ArrayList<Planning> planArraylist) {
this.context = context;
this.planArraylist = planArraylist;
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
databaseHelper = new Db_sqlite(context);
}
@Override
public int getCount() {
return planArraylist.size();
}
@Override
public Planning getItem(int arg0) {
return planArraylist.get(arg0);
}
@Override
public long getItemId(int arg0) {
return arg0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
convertView = inflater.inflate(R.layout.single_lv_item, parent, false);
holder = new ViewHolder();
holder.tvdrCode =(TextView)onvertView.findViewById(R.id.Plan_no);
holder.tvDrName = (TextView) convertView.findViewById(R.id.doc_name);
holder.tvterrcode= (TextView) convertView.findViewById(R.id.mon);
holder.tvAdr = (TextView) convertView.findViewById(R.id.adr);
holder.tvClassDesc = (TextView) convertView.findViewById(R.id.class_desc);
holder.tvspeciality = (TextView) convertView.findViewById(R.id.ff_code);
holder.tvAreaName = (TextView) convertView.findViewById(R.id.area_name);
holder.tvShift = (TextView) convertView.findViewById(R.id.shift);
holder.btn_visited =(Button)convertView.findViewById(R.id.button1);
holder.btn_visited.setTag(position);
holder.btn_visited.setOnClickListener(ButtonClickListener);
convertView.setTag(holder);
}
else {
holder = (ViewHolder) convertView.getTag();
}
Planning p = planArraylist.get(position);
holder.tvdrCode.setText(p.getDocCode());
holder.tvDrName.setText(p.getDocName());
holder.tvterrcode.setText(p.getTerrCode());
holder.tvAdr.setText(p.getAdr());
holder.tvClassDesc.setText(p.getClassDesc());
holder.tvspeciality.setText(p.getSP());
holder.tvAreaName.setText(p.getAreaName());
holder.tvShift.setText(p.getMornEven());
return convertView;
}
static class ViewHolder {
TextView tvdrCode;
TextView tvDrName;
TextView tvterrcode;
TextView tvAdr;
TextView tvClassDesc;
TextView tvspeciality;
TextView tvAreaName;
TextView tvShift;
Button btn_visited;
}
private OnClickListener ButtonNotVistedClickListener = new OnClickListener(){
public void onClick(View v) {
final int position = (Integer) v.getTag(); //2nd method String d = planArraylist.get(position).getDocCode();
Planning planning = getItem(position);
String replan_no = "1";
String drCode = planning.getDocCode();
String terrcode = planning.getTerrCode();
String prev_plan_date = currentDate;
String replan_date = currentDate;
String shift = planning.getMornEven();
String created_date =currentDate;
String nvr_no = "783882";
String Sffcode = PlanningList_activity.FFCODE;
String Sffmgr= PlanningList_activity.FFMGR;
Intent intent=new Intent(context.getApplicationContext(),NotVisited_Activtiy.class); // goto to attendance class
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Bundle userBundle = new Bundle();
userBundle.putString("DR_CODE", planning.getDocCode());
userBundle.putString("DR_NAME",planning.getDocName());
userBundle.putString("TERR_CODE", planning.getTerrCode());
userBundle.putString("ADR", planning.getAdr());
userBundle.putString("CLASS_DESC", planning.getClassDesc());
userBundle.putString("SPECIALITY", planning.getSP());
userBundle.putString("AREA_NAME", planning.getAreaName());
userBundle.putString("SHIFT", planning.getMornEven());
intent.putExtras(userBundle);
context.startActivity(intent);
}
};
private OnClickListener ButtonClickListener = new OnClickListener() {
public void onClick(View v) {
final int position = (Integer) v.getTag(); //2nd method String d = planArraylist.get(position).getDocCode();
Planning planning = getItem(position);
String dcr_date = currentDate;
String drCode = planning.getDocCode();
String shift = planning.getMornEven();
String terrcode = planning.getTerrCode();
String created_date =currentDate;
String ref_no = "SLS51";
String Sffcode = PlanningList_activity.FFCODE;
String Sffmgr= PlanningList_activity.FFMGR;
Dcr_main dvr = new Dcr_main(dcr_date,drCode,shift,Sffcode,terrcode,Sffmgr,created_date,ref_no);
new SaveDCR(context).execute(dvr);
}
};
protected class SaveDCR extends AsyncTask<Dcr_main, Void, Void> {
Context mcontext;
ProgressDialog progressDialog;
public SaveDCR(Context mcontext) {
// TODO Auto-generated constructor stub
this.mcontext = mcontext;
}
@Override
protected void onPreExecute() {
progressDialog = new ProgressDialog(mcontext);
progressDialog.setMessage("Saving...");
progressDialog.setCancelable(false);
progressDialog.show();
Log.e("sending dvr to sqlite","yes");
}
@Override
protected Void doInBackground(Dcr_main... params) {
RestAPI api = new RestAPI();
try
{
// insert into device database
databaseHelper.insertDVR(params[0].getDcr_Date(),
params[0].getDr_Code(),
params[0].getShift(),
params[0].getFf_code(),
params[0].getTerr_code(),
params[0].getFF_mgr(),
params[0].getCreatedDate(),
params[0].getRef_no());
Log.e(" inserting dvr in sqlite","yes");
databaseHelper .close();
api.DVRInsert(params[0].getDcr_Date(),
params[0].getDr_Code(),
params[0].getShift(),
params[0].getFf_code(),
params[0].getTerr_code(),
params[0].getFF_mgr(),
params[0].getRef_no());
Log.e("sent dvr to server, do inbackground","yes");
}
catch (Exception e) {
// TODO Auto-generated catch block
Log.d("Failed to connect to server", e.getMessage());
}
return null;
}
@Override
protected void onPostExecute(Void result) {
if(progressDialog.isShowing()) {
progressDialog.dismiss();
}
}
}
나는이 문제를 파악할 수 없다. 대단히 죄송합니다. 미리 감사드립니다. 로그인 고양이 오류
대신 preExecute 방법에02-09 12:22:51.932: E/AndroidRuntime(26893): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
02-09 12:22:51.932: E/AndroidRuntime(26893): at android.view.ViewRootImpl.setView(ViewRootImpl.java:540)
02-09 12:22:51.932: E/AndroidRuntime(26893): at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:259)
02-09 12:22:51.932: E/AndroidRuntime(26893): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
02-09 12:22:51.932: E/AndroidRuntime(26893): at android.app.Dialog.show(Dialog.java:286)
02-09 12:22:51.932: E/AndroidRuntime(26893): at com.example.db_client.PlannningListViewAdapter$SaveDCR.onPreExecute(PlannningListViewAdapter.java:235)
02-09 12:22:51.932: E/AndroidRuntime(26893): at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:587)
02-09 12:22:51.932: E/AndroidRuntime(26893): at android.os.AsyncTask.execute(AsyncTask.java:535)
02-09 12:22:51.932: E/AndroidRuntime(26893): at com.example.db_client.PlannningListViewAdapter$2.onClick(PlannningListViewAdapter.java:213)
02-09 12:22:51.932: E/AndroidRuntime(26893): at android.view.View.performClick(View.java:4438)
02-09 12:22:51.932: E/AndroidRuntime(26893): at android.view.View$PerformClick.run(View.java:18422)
02-09 12:22:51.932: E/AndroidRuntime(26893): at android.os.Handler.handleCallback(Handler.java:733)
02-09 12:22:51.932: E/AndroidRuntime(26893): at android.os.Handler.dispatchMessage(Handler.java:95)
당신이 충돌 로그를하시기 바랍니다 붙여 넣을 수 님의
변경하세요? – staaar
이 생성자 PlannningListViewAdapter로 전달할 대상은 무엇입니까? –
당신은 문맥을 말하는 것을 의미합니까? – Andrain