/**
   * Display extra help, triggered by user request.
   *
   * @param prompt
   */
  private void fireHelpText(FormEntryPrompt prompt) {
    if (!prompt.hasHelp()) {
      return;
    }

    // Depending on ODK setting, help may be displayed either as
    // a dialog or inline, underneath the question text
    if (!PreferenceManager.getDefaultSharedPreferences(this.getContext().getApplicationContext())
        .getBoolean(PreferencesActivity.KEY_HELP_MODE_TRAY, false)) {
      AlertDialog mAlertDialog = new AlertDialog.Builder(this.getContext()).create();
      mAlertDialog.setIcon(android.R.drawable.ic_dialog_info);
      mAlertDialog.setTitle("");

      ScrollView scrollView = new ScrollView(this.getContext());
      scrollView.addView(createHelpLayout(prompt));
      mAlertDialog.setView(scrollView);

      DialogInterface.OnClickListener errorListener =
          new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int i) {
              switch (i) {
                case DialogInterface.BUTTON1:
                  dialog.cancel();
                  break;
              }
            }
          };
      mAlertDialog.setCancelable(true);
      mAlertDialog.setButton(
          StringUtils.getStringRobust(this.getContext(), R.string.ok), errorListener);
      mAlertDialog.show();
    } else {
      if (helpPlaceholder.getVisibility() == View.GONE) {
        expand(helpPlaceholder);
      } else {
        collapse(helpPlaceholder);
      }
    }
  }
  private void addHelpPlaceholder(FormEntryPrompt p) {
    if (!p.hasHelp()) {
      return;
    }

    helpPlaceholder = new FrameLayout(this.getContext());
    helpPlaceholder.setLayoutParams(
        new FrameLayout.LayoutParams(
            FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT));

    ImageButton trigger = new ImageButton(getContext());
    trigger.setImageResource(android.R.drawable.ic_menu_help);
    final FormEntryPrompt prompt = p;
    trigger.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            fireHelpText(prompt);
          }
        });
    trigger.setId(847294011);
    LinearLayout triggerLayout = new LinearLayout(getContext());
    triggerLayout.setOrientation(LinearLayout.HORIZONTAL);
    triggerLayout.setLayoutParams(
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
    triggerLayout.setGravity(Gravity.RIGHT);
    triggerLayout.addView(trigger);

    MediaLayout helpLayout = createHelpLayout(p);
    helpLayout.setBackgroundResource(color.very_light_blue);
    helpPlaceholder.addView(helpLayout);

    this.addView(triggerLayout);
    this.addView(helpPlaceholder);
    helpPlaceholder.setVisibility(View.GONE);
  }