@Override
  public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    AdapterView.AdapterContextMenuInfo info;
    try {
      // Casts the incoming data object into the type for AdapterView objects.
      info = (AdapterView.AdapterContextMenuInfo) menuInfo;
    } catch (ClassCastException e) {
      // If the menu object can't be cast, logs an error.
      Log.e(TAG, "bad menuInfo", e);
      return;
    }
    StrngData strngdata = strngdata_adapter.getItem(info.position);

    menu.setHeaderTitle("Action: " + strngdata.toString());

    getActivity().getMenuInflater().inflate(R.menu.string_list_item_context, menu);
  }
  @Override
  public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info =
        (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    int position = info.position;
    StrngData strngdata = strngdata_adapter.getItem(position);

    switch (item.getItemId()) {
      case R.id.menu_item_edit_string:
        Intent i = new Intent(getActivity(), StrngDataActivity.class);
        i.putExtra(StrngDataFragment.EXTRA_RACKET_ID, mRacket.getId());
        i.putExtra(StrngDataFragment.EXTRA_STRINGDATA_ID, strngdata.getId());
        startActivityForResult(i, REQUEST_STRING);
        return true;
      case R.id.menu_item_delete_string:
        alertMessageDeleteString(strngdata);
        return true;
    }
    return super.onContextItemSelected(item);
  }
  private void addCalendarEvent() {
    // Peter:
    // http://code.tutsplus.com/tutorials/android-essentials-adding-events-to-the-users-calendar--mobile-8363
    // Crashes: Intent intent = new Intent(Intent.ACTION_INSERT);
    // Crashes: intent.setData(CalendarContract.Events.CONTENT_URI);
    Intent intent = new Intent(Intent.ACTION_EDIT); // ACTION_INSERT causes crash
    intent.setType("vnd.android.cursor.item/event");

    intent.putExtra(CalendarContract.Events.TITLE, "Restring: " + mRacket.getName());

    StrngData c = mRacket.getStrngDataByLastDate(); // retrieve string data
    SimpleDateFormat sdf = new SimpleDateFormat("MMM dd yyyy");
    if (c == null) {
      // No string data - use racket data
      intent.putExtra(CalendarContract.Events.EVENT_LOCATION, mRacket.getPurchaseLocation());
      intent.putExtra(
          CalendarContract.Events.DESCRIPTION, "String Tension: " + mRacket.getStringTension());
    } else {
      // Use string data
      intent.putExtra(CalendarContract.Events.EVENT_LOCATION, c.getLocation());
      intent.putExtra(
          CalendarContract.Events.DESCRIPTION,
          "Last String Date: "
              + sdf.format(c.getDate())
              + "\nMains: "
              + c.getMainTension()
              + "\nCrosses: "
              + c.getCrossTension());
    }

    GregorianCalendar calDate = new GregorianCalendar(); // default to today's date
    intent.putExtra(CalendarContract.EXTRA_EVENT_ALL_DAY, true);
    intent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, calDate.getTimeInMillis());
    intent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME, calDate.getTimeInMillis());

    startActivity(intent);
  }
  private void alertMessageDeleteString(final StrngData strngdata) {
    AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity());

    // Setting Dialog Title
    alertDialog.setTitle("Confirm Delete...");

    // Setting Dialog Message
    alertDialog.setMessage("Delete " + strngdata.toString() + "?");

    // Setting Icon to Dialog
    // alertDialog.setIcon(R.drawable.delete);

    // Setting Positive "Yes" Button
    alertDialog.setPositiveButton(
        "YES",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            // Yes button clicked
            UUID racketId =
                (UUID)
                    getActivity()
                        .getIntent()
                        .getSerializableExtra(
                            RacketFragment.EXTRA_RACKET_ID); // chapter 10: direct method:
            RacketList.get(getActivity()).getRacket(racketId).deleteStrngData(strngdata);
            RacketList.get(getActivity())
                .saveRackets(); // kluge: could not be done in deleteStrngData
            strngdata_adapter.notifyDataSetChanged();
          }
        });

    // Setting Negative "NO" Button
    alertDialog.setNegativeButton(
        "NO",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            // No button clicked
            // do nothing
            dialog.cancel();
          }
        });

    // Showing Alert Message
    alertDialog.show();
  }