Example usage for android.view ViewStub setLayoutResource

List of usage examples for android.view ViewStub setLayoutResource

Introduction

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

Prototype

@android.view.RemotableViewMethod(asyncImpl = "setLayoutResourceAsync")
public void setLayoutResource(@LayoutRes int layoutResource) 

Source Link

Document

Specifies the layout resource to inflate when this StubbedView becomes visible or invisible or when #inflate() is invoked.

Usage

From source file:org.openhab.habdroid.ui.activity.ContentControllerOnePane.java

@Override
public void inflateViews(ViewStub stub) {
    stub.setLayoutResource(R.layout.content_onepane);
    stub.inflate();
}

From source file:org.openhab.habdroid.ui.activity.ContentControllerTwoPane.java

@Override
public void inflateViews(ViewStub stub) {
    stub.setLayoutResource(R.layout.content_twopane);
    View view = stub.inflate();/* ww  w  .  j  av a  2  s.co m*/
    mRightContentView = view.findViewById(R.id.content_right);
    mRightContentView.setVisibility(View.GONE);
}

From source file:ro.expectations.expenses.ui.backup.FinancistoImportActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.app_bar);/*from  w  w  w .  j a  v  a 2  s. c  om*/

    ViewStub mainContent = (ViewStub) findViewById(R.id.main_content);
    mainContent.setLayoutResource(R.layout.content_backup);
    mainContent.inflate();

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setVisibility(View.GONE);

    mAppBarLayout = (AppBarLayout) findViewById(R.id.app_bar);

    if (savedInstanceState == null) {
        FinancistoImportFragment fragment = FinancistoImportFragment.newInstance();
        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
        transaction.add(R.id.fragment, fragment);
        transaction.commit();
    }
}

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

/**
 * Inflates the <code>ViewStub</code> with the passed layout resource.
 *//*from  w  ww. j  a v  a  2  s .  co 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();
        }
    };
}

From source file:ro.expectations.expenses.ui.categories.SubcategoriesActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mParentCategoryId = getIntent().getLongExtra(ARG_PARENT_CATEGORY_ID, 0);
    if (mParentCategoryId == 0) {
        Intent categoryIntent = new Intent(this, CategoriesActivity.class);
        startActivity(categoryIntent);/*from  w  w w.  ja v  a2s.  co m*/
    }

    setContentView(R.layout.app_bar);

    ViewStub mainContent = (ViewStub) findViewById(R.id.main_content);
    mainContent.setLayoutResource(R.layout.content_categories);
    mainContent.inflate();

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setDisplayShowTitleEnabled(false);
    }

    getSupportLoaderManager().initLoader(0, null, this);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Not yet implemented", Snackbar.LENGTH_LONG).setAction("OK", null).show();
        }
    });

    mAppBarLayout = (AppBarLayout) findViewById(R.id.app_bar);

    if (savedInstanceState == null) {
        CategoriesFragment fragment = CategoriesFragment.newInstance(mParentCategoryId);
        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
        transaction.add(R.id.fragment, fragment);
        transaction.commit();
    }
}

From source file:bander.notepad.PrefsActivityAppCompat.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Notepad.setAppCompatThemeFromPreferences(this, "Prefs");
    setContentView(R.layout.preferences_toolbar);

    SharedPreferences mSettings = PreferenceManager.getDefaultSharedPreferences(this);

    ViewStub stub = (ViewStub) findViewById(R.id.toolbarWrapper);
    if (mSettings.getBoolean("darkAppCompatTheme", false))
        stub.setLayoutResource(R.layout.toolbar_dark);
    else//  w  w  w .  j  a v  a 2  s .co m
        stub.setLayoutResource(R.layout.toolbar_light);
    stub.inflate();
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    Notepad.setToolbarColor(this);
    setSupportActionBar(toolbar);
    if (mSettings.getBoolean("darkAppCompatTheme", false))
        toolbar.setNavigationIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
    else
        toolbar.setNavigationIcon(
                IconTintFactory.setDarkMaterialColor(R.drawable.abc_ic_ab_back_mtrl_am_alpha, this));

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onBackPressed();
        }
    });
    // Starting the Fragment
    Log.i("INFO", "Starting PreferenceFragment...");

    FragmentManager manager = getSupportFragmentManager();
    FragmentTransaction transaction = manager.beginTransaction();
    transaction.replace(R.id.prefContent, myFragment);
    transaction.commit();
}

From source file:com.zhi.android.modules.welcome.WelcomePageFragment.java

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    final ViewStub stub = view.findViewById(R.id.welcome_layout);
    if (mPageOption.layout != 0) {
        stub.setLayoutResource(mPageOption.layout);
        final View warmView = stub.inflate();
        warmView.setTag(warmViewTag(mPageIndex));
        warmView.setTag(R.id.welcome_layout, new WarmInfo(warmView, getResources()));
    }/*from  ww  w  . java  2s. c  o  m*/

    final TextView primaryView = view.findViewById(R.id.welcome_primary);
    if (mPageOption.primary != 0) {
        primaryView.setText(mPageOption.primary);
    }

    final TextView blurbView = view.findViewById(R.id.welcome_blurb);
    if (mPageOption.blurb != 0) {
        blurbView.setText(mPageOption.blurb);
    }
}

From source file:com.tomeokin.lspush.biz.home.CollectionWebViewActivity.java

@Override
protected void onPrepareInflater(ViewStub container) {
    container.setLayoutResource(R.layout.layout_collection_web_view_bottom_bar);
    View bottomBarView = container.inflate();
    mBottomBar = new BottomBar(bottomBarView);
}

From source file:com.teamltt.carcare.activity.BaseActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (includeDrawer) {
        setContentView(R.layout.activity_base);
    } else {/*  w  ww  .  j  av  a2s . co m*/
        setContentView(R.layout.app_bar_base);
    }
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    if (drawer != null) {
        ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar,
                R.string.navigation_drawer_open, R.string.navigation_drawer_close);
        drawer.addDrawerListener(toggle);
        toggle.syncState();

        NavigationView navigationViewTop = (NavigationView) findViewById(R.id.nav_view_top);
        NavigationView navigationViewBottom = (NavigationView) findViewById(R.id.nav_view_bottom);
        if (navigationViewTop != null && navigationViewBottom != null) {
            navigationViewTop.setNavigationItemSelectedListener(this);
            navigationViewBottom.setNavigationItemSelectedListener(this);
        }

        drawer.findViewById(R.id.nav_view_top).bringToFront();
        drawer.findViewById(R.id.nav_view_bottom).bringToFront();
    }

    ViewStub stub = (ViewStub) findViewById(R.id.content_base);
    if (stub != null) {
        stub.setLayoutResource(activityContent);
        stub.inflate();
    }

    buildNewGoogleApiClient();
}

From source file:com.android.settings.PreviewPagerAdapter.java

public PreviewPagerAdapter(Context context, boolean isLayoutRtl, int[] previewSampleResIds,
        Configuration[] configurations) {
    mIsLayoutRtl = isLayoutRtl;/* w  w  w.j a va  2 s .c  o  m*/
    mPreviewFrames = new FrameLayout[previewSampleResIds.length];
    mViewStubInflated = new boolean[previewSampleResIds.length][configurations.length];

    for (int i = 0; i < previewSampleResIds.length; ++i) {
        int p = mIsLayoutRtl ? previewSampleResIds.length - 1 - i : i;
        mPreviewFrames[p] = new FrameLayout(context);
        mPreviewFrames[p].setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.MATCH_PARENT));

        for (int j = 0; j < configurations.length; ++j) {
            // Create a new configuration for the specified value. It won't
            // have any theme set, so manually apply the current theme.
            final Context configContext = context.createConfigurationContext(configurations[j]);
            configContext.setTheme(context.getThemeResId());

            final LayoutInflater configInflater = LayoutInflater.from(configContext);
            final ViewStub sampleViewStub = new ViewStub(configContext);
            sampleViewStub.setLayoutResource(previewSampleResIds[i]);
            final int fi = i, fj = j;
            sampleViewStub.setOnInflateListener(new OnInflateListener() {
                @Override
                public void onInflate(ViewStub stub, View inflated) {
                    inflated.setVisibility(stub.getVisibility());
                    mViewStubInflated[fi][fj] = true;
                }
            });

            mPreviewFrames[p].addView(sampleViewStub);
        }
    }
}