ImageButton action_btn = (ImageButton) findViewById(R.id.action_btn); action_btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { //数据校验//暂StringEx.isNull(mHouselist_houseid_view.getText().toString())|| if(isOperateAdd){ if( StringEx.isNull(mDeptcode_view.getText().toString()) ||StringEx.isNull(mFamilyorder_view.getText().toString()) ||StringEx.isNull(mPname_view.getText().toString()) ||StringEx.isNull(mIdnumber_view.getText().toString()) ||StringEx.isNull(mMobile_view.getText().toString())){ Toast.makeText(EditPersonActivity.this, "请输入完整信息", Toast.LENGTH_SHORT) .show(); return; } } else{ if(StringEx.isNull(mPname_view.getText().toString()) ||StringEx.isNull(mIdnumber_view.getText().toString()) ||StringEx.isNull(mMobile_view.getText().toString())){ Toast.makeText(EditPersonActivity.this, "请输入完整信息", Toast.LENGTH_SHORT) .show(); return; } } //字符限制--身份证号 if(!StringEx.isNull(mIdnumber_view.getText().toString())){ try { String a = IDCardAndMobile.IDCardValidate(mIdnumber_view.getText().toString()); if(("").equals(a)){ mIdnumber_view.setText(mIdnumber_view.getText().toString()); }else{ Toast.makeText(EditPersonActivity.this, "身份证号输入错误", Toast.LENGTH_SHORT) .show(); mIdnumber_view.setText(""); return; } }catch (ParseException e){ e.printStackTrace(); } } //字符限制--手机号 if(!StringEx.isNull(mMobile_view.getText().toString())){ try { boolean a = IDCardAndMobile.isMobileNO(mMobile_view.getText().toString()); if(a){ mMobile_view.setText(mMobile_view.getText().toString()); }else{ Toast.makeText(EditPersonActivity.this, "手机号码输入错误", Toast.LENGTH_SHORT) .show(); mMobile_view.setText(""); return; } }catch (Exception e){ e.printStackTrace(); } } if(mBitmap==null){ Toast.makeText(EditPersonActivity.this, "请点击照相", Toast.LENGTH_SHORT) .show(); }else{ compressImageFile = Tools.compressImage(mBitmap); new Thread(new Runnable() { @Override public void run() { try { jsonObject = new JSONObject(); jsonObject.put("singlefamily", mSinglefamily_view.getText()); jsonObject.put("houseid", mHouselist_houseid_view.getText()); jsonObject.put("familyorder", mFamilyorder_view.getText()); jsonObject.put("pname", mPname_view.getText()); jsonObject.put("relation", mRelation_view.getText()); jsonObject.put("gender", mGender_view.getText()); jsonObject.put("idnumber", mIdnumber_view.getText()); jsonObject.put("mobile", mMobile_view.getText()); jsonObject.put("persontype", mPersontype_view.getText()); jsonObject.put("religion", mReligion_view.getText()); jsonObject.put("maritalstatus", mMaritalstatus_view.getText()); jsonObject.put("military", mMilitary_view.getText()); jsonObject.put("education", mEducation_view.getText()); jsonObject.put("registertype", mRegistertype_view.getText()); jsonObject.put("remark", mRemark_view.getText()); String res; Intent intent = new Intent(); if(isOperateAdd){ jsonObject.put("deptcode", mDeptcode_view.getText()); res = HttpClientUtil.getStringFromServer(Constants.SERVER_URL+"/personHouseHolder/addHouseHolderBasic_App.jspx", jsonObject, compressImageFile); } else { jsonObject.put("personid", mPersonid); res = HttpClientUtil.getStringFromServer(Constants.SERVER_URL+"/personHouseHolder/updateHouseHolderBasic_App.jspx", jsonObject, compressImageFile); } intent.putExtra("result", res); setResult(RESULT_OK, intent); finish(); } catch (JSONException e) { e.printStackTrace(); } catch (IOException e){ } } }).start(); } } });