Example usage for android.view ViewStub getInflatedId

List of usage examples for android.view ViewStub getInflatedId

Introduction

In this page you can find the example usage for android.view ViewStub getInflatedId.

Prototype

@IdRes
public int getInflatedId() 

Source Link

Document

Returns the id taken by the inflated view.

Usage

From source file:android.support.design.widget.BaseDynamicCoordinatorLayoutTest.java

/**
 * Inflates the <code>ViewStub</code> with the passed layout resource.
 *///from   ww  w. j  a va 2s . c o m
protected ViewAction inflateViewStub(final @LayoutRes int layoutResId) {
    return new ViewAction() {
        @Override
        public Matcher<View> getConstraints() {
            return allOf(isAssignableFrom(ViewStub.class), hasParent());
        }

        @Override
        public String getDescription() {
            return "Inflates view stub";
        }

        @Override
        public void perform(UiController uiController, View view) {
            uiController.loopMainThreadUntilIdle();

            ViewStub viewStub = (ViewStub) view;
            viewStub.setLayoutResource(layoutResId);
            viewStub.inflate();

            mCoordinatorLayout = (CoordinatorLayout) mActivityTestRule.getActivity()
                    .findViewById(viewStub.getInflatedId());

            uiController.loopMainThreadUntilIdle();
        }
    };
}