List of usage examples for android.view ViewGroup setAccessibilityDelegate
public void setAccessibilityDelegate(@Nullable AccessibilityDelegate delegate)
From source file:com.google.android.marvin.talkback.tutorial.TutorialModule.java
/** * Constructs a new tutorial module for the given tutorial activity context * with the specified layout and title./*from w ww . ja va 2 s.c om*/ * * @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); } }
From source file:com.android.screenspeak.tutorial.TutorialModule.java
/** * Constructs a new tutorial module for the given tutorial activity context * with the specified layout and title./*ww w . j a va 2s . c om*/ * * @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. */ 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 // A delegate used to drop accessibility events related to AbsListView's // inflation of module content. contentHolder.setAccessibilityDelegate(new AccessibilityDelegate() { @Override public boolean onRequestSendAccessibilityEvent(@NonNull ViewGroup host, View child, AccessibilityEvent event) { return event.getEventType() != AccessibilityEvent.TYPE_VIEW_SCROLLED && super.onRequestSendAccessibilityEvent(host, child, event); } }); inflater.inflate(layoutResId, contentHolder, true); contentHolder.setAccessibilityDelegate(null); } }