Beispiel #1
0
  /**
   * Constructs a new tutorial module for the given tutorial activity context with the specified
   * layout and title.
   *
   * @param parentTutorial The tutorial activity containing this module.
   * @param layoutResId The resource identifier for this module's layout.
   * @param titleResId The resource identifier for this module's title string.
   */
  public TutorialModule(
      AccessibilityTutorialActivity parentTutorial, int layoutResId, int titleResId) {
    super(parentTutorial);

    mParentTutorial = parentTutorial;
    mTitleResId = titleResId;

    final LayoutInflater inflater = mParentTutorial.getLayoutInflater();
    final View container = inflater.inflate(R.layout.tutorial_container, this, true);

    mInstructions = (TextView) container.findViewById(R.id.instructions);
    mSkip = (Button) container.findViewById(R.id.skip_button);
    mSkip.setOnClickListener(this);
    mBack = (Button) container.findViewById(R.id.back_button);
    mBack.setOnClickListener(this);
    mNext = (Button) container.findViewById(R.id.next_button);
    mNext.setOnClickListener(this);
    mFinish = (Button) container.findViewById(R.id.finish_button);
    mFinish.setOnClickListener(this);

    final TextView title = (TextView) container.findViewById(R.id.title);

    if (title != null) {
      title.setText(titleResId);
    }

    if (layoutResId != -1) {
      final ViewGroup contentHolder = (ViewGroup) container.findViewById(R.id.content);

      // Inflate the tutorial module content while dropping certain accessibility events
      contentHolder.setAccessibilityDelegate(mDropEventsDelegate);
      inflater.inflate(layoutResId, contentHolder, true);
      contentHolder.setAccessibilityDelegate(null);
    }
  }