@Override
  public boolean onOptionsItemSelected(MenuItem item) {
    // Handle item selection
    switch (item.getItemId()) {
      case R.id.orderitem:
        if (Constants.orderList.size() > 0) {
          // finish();
          Intent i = new Intent(CardOrder.this, CardInfoActivity.class);
          startActivity(i);
        } else {
          Toast.makeText(CardOrder.this, "選択してください。", Toast.LENGTH_SHORT).show();
        }
        return true;

      case R.id.deleteitem:
        if (Constants.orderList.size() == 1) {
          Response response;
          try {
            if (CheckInternet.checkConn(CardOrder.this)) {
              response = Utility.deleteFromCardOrder(Constants.userName);
            } else {
              response = null;
            }
            if (response.getStatus().equals("OK")) {

              finish();
              startActivity(new Intent(CardOrder.this, CardOrder.class));
              Constants.orderList.clear();
              Toast.makeText(this, "削除しました", Toast.LENGTH_LONG).show();
            } else {
              Toast.makeText(this, "削除することができません。", Toast.LENGTH_LONG).show();
            }

            return true;

          } catch (Exception e) {
            Toast.makeText(this, e + "", Toast.LENGTH_LONG).show();
          }
        } else {
          Toast.makeText(this, "削除することができません。", Toast.LENGTH_LONG).show();
        }
      default:
        return super.onOptionsItemSelected(item);
    }
  }
  private void PopulateListByJSONArray() {

    try {
      String newtime = Utility.getdate();
      String accesskey = Utility.MD5_Hash(Constants.email + newtime + "moko");
      Constants.ACCESS_KEY = accesskey;
      Constants.proc_date = newtime;
      JSONArray response;
      if (CheckInternet.checkConn(PurchaseHistory.this)) {
        response = Utility.getPurchaseHistory();
      } else {
        response = null;
      }

      if (response != null) {

        for (int i = 0; i < response.length(); i++) {

          JSONObject jObj = response.getJSONObject(i);

          JSONArray cardsArray = jObj.getJSONArray("cards");

          String orderCreationDate = jObj.getString("created_at");

          for (int j = 0; j < cardsArray.length(); j++) {
            JSONObject jo = cardsArray.getJSONObject(j).getJSONObject("card");
            PurchaseHistoryEntity purchaseHistoryEntity = new PurchaseHistoryEntity();

            purchaseHistoryEntity.set_original_image_url(jo.getString("original_image_url"));

            purchaseHistoryEntity.setBuilding(jo.getString("building"));
            purchaseHistoryEntity.setAddress1(jo.getString("address1"));
            purchaseHistoryEntity.setZip(jo.getString("zip"));
            purchaseHistoryEntity.setSei(jo.getString("sei"));
            purchaseHistoryEntity.set_mail_address(jo.getString("email"));

            purchaseHistoryEntity.set_file_path(jo.getString("file_path"));
            purchaseHistoryEntity.set_created_at(jo.getString("created_at"));
            purchaseHistoryEntity.setAddress2(jo.getString("address2"));
            purchaseHistoryEntity.set_company_name(jo.getString("company_name"));
            purchaseHistoryEntity.set_company_kana(jo.getString("company_kana"));
            purchaseHistoryEntity.setAddress3(jo.getString("address3"));
            purchaseHistoryEntity.set_updated_at(jo.getString("updated_at"));
            purchaseHistoryEntity.set_proc_card_id(jo.getString("proc_card_id"));
            purchaseHistoryEntity.setUrl(jo.getString("url"));
            purchaseHistoryEntity.set_status_ja(jo.getString("status_ja"));

            purchaseHistoryEntity.setSeimei(jo.getString("seimei"));
            purchaseHistoryEntity.setMemo(jo.getString("memo"));
            purchaseHistoryEntity.setKeitai(jo.getString("keitai"));
            purchaseHistoryEntity.setAddress4(jo.getString("address4"));
            // purchaseHistoryEntity.setYakusyoku(jo.getString("yakusyoku"));
            purchaseHistoryEntity.set_thumbnail_image_url1(jo.getString("thumbnail_image_url1"));
            purchaseHistoryEntity.set_thumbnail_image_url2(jo.getString("thumbnail_image_url2"));
            purchaseHistoryEntity.set_thumbnail_image_url3(jo.getString("thumbnail_image_url3"));
            purchaseHistoryEntity.set_thumbnail_image_url4(jo.getString("thumbnail_image_url4"));
            purchaseHistoryEntity.setTel(jo.getString("tel"));

            purchaseHistoryEntity.set_mei_kana(jo.getString("mei_kana"));
            purchaseHistoryEntity.setId(jo.getString("id"));
            purchaseHistoryEntity.set_file_name(jo.getString("file_name"));
            purchaseHistoryEntity.set_user_id(jo.getString("user_id"));
            purchaseHistoryEntity.setMei(jo.getString("mei"));
            purchaseHistoryEntity.set_file_size(jo.getString("file_size"));
            /*	purchaseHistoryEntity.set_file_extension(jo
            .getString("file_extension"));*/
            purchaseHistoryEntity.setFax(jo.getString("fax"));
            purchaseHistoryEntity.set_sei_kana(jo.getString("sei_kana"));
            // watchListAllEntity.setBusyo(jo.getString("busyo"));
            purchaseHistoryEntity.setStatus(jo.getString("status"));
            purchaseHistoryEntity.set_order_created_at(orderCreationDate);
            purchaseHistoryEntity.set_order_amount(cardsArray.length() + "");

            listrow.add(purchaseHistoryEntity);
          }
        }
      }

    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    runOnUiThread(returnRes);
  }
  private void PopulateListByJSONArray() {

    try {
      String newtime = Utility.getdate();
      String accesskey = Utility.MD5_Hash(Constants.email + newtime + "moko");
      Constants.ACCESS_KEY = accesskey;
      Constants.proc_date = newtime;
      if (CheckInternet.checkConn(CardOrder.this)) {
        response = Utility.getAllList();
      } else {
        response = null;
      }
      if (response != null) {

        for (int i = 0; i < response.length(); i++) {
          WatchListAllEntity watchListAllEntity = new WatchListAllEntity();
          // String s=(String) response.getJSONObject(i).get("card");
          JSONObject jo = response.getJSONObject(i).getJSONObject("card");

          watchListAllEntity.set_original_image_url(jo.getString("original_image_url"));

          watchListAllEntity.setBuilding(jo.getString("building"));
          watchListAllEntity.setAddress1(jo.getString("address1"));
          watchListAllEntity.setZip(jo.getString("zip"));
          watchListAllEntity.setSei(jo.getString("sei"));

          watchListAllEntity.set_mail_address(jo.getString("email"));

          watchListAllEntity.set_file_path(jo.getString("file_path"));
          watchListAllEntity.set_created_at(jo.getString("created_at"));
          watchListAllEntity.setAddress2(jo.getString("address2"));
          watchListAllEntity.set_company_name(jo.getString("company_name"));
          watchListAllEntity.set_company_kana(jo.getString("company_kana"));
          watchListAllEntity.setAddress3(jo.getString("address3"));
          watchListAllEntity.set_updated_at(jo.getString("updated_at"));
          watchListAllEntity.set_proc_card_id(jo.getString("proc_card_id"));
          watchListAllEntity.setUrl(jo.getString("url"));
          watchListAllEntity.set_status_ja(jo.getString("status_ja"));

          watchListAllEntity.setSeimei(jo.getString("seimei"));
          watchListAllEntity.setMemo(jo.getString("memo"));
          watchListAllEntity.setKeitai(jo.getString("keitai"));
          watchListAllEntity.setAddress4(jo.getString("address4"));
          // watchListAllEntity.setYakusyoku(jo.getString("yakusyoku"));
          watchListAllEntity.set_thumbnail_image_url1(jo.getString("thumbnail_image_url1"));
          Drawable image =
              Utility.ImageOperations(
                  jo.getString("thumbnail_image_url1").replace(" ", "%20"), "image.jpg");

          watchListAllEntity.setImage(image);
          watchListAllEntity.set_thumbnail_image_url2(jo.getString("thumbnail_image_url2"));
          watchListAllEntity.set_thumbnail_image_url3(jo.getString("thumbnail_image_url3"));
          watchListAllEntity.set_thumbnail_image_url4(jo.getString("thumbnail_image_url4"));
          Log.e(
              "Url1,Url2,Url3,Url4",
              jo.getString("thumbnail_image_url1")
                  + ","
                  + jo.getString("thumbnail_image_url2")
                  + ","
                  + jo.getString("thumbnail_image_url3")
                  + ","
                  + jo.getString("thumbnail_image_url4")
                  + "");
          watchListAllEntity.setTel(jo.getString("tel"));

          watchListAllEntity.set_mei_kana(jo.getString("mei_kana"));
          watchListAllEntity.setId(jo.getString("id"));
          watchListAllEntity.set_file_name(jo.getString("file_name"));
          watchListAllEntity.set_user_id(jo.getString("user_id"));
          watchListAllEntity.setMei(jo.getString("mei"));
          watchListAllEntity.set_file_size(jo.getString("file_size"));
          /*
           * watchListAllEntity.set_file_extension(jo
           * .getString("file_extension"));
           */
          watchListAllEntity.setFax(jo.getString("fax"));
          watchListAllEntity.set_sei_kana(jo.getString("sei_kana"));
          // watchListAllEntity.setBusyo(jo.getString("busyo"));
          watchListAllEntity.setStatus(jo.getString("status"));

          listrow.add(watchListAllEntity);
        }
      }

    } catch (JSONException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    runOnUiThread(returnRes);
  }