List of usage examples for android.view ViewStub inflate
public View inflate()
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(); mRightContentView = view.findViewById(R.id.content_right); mRightContentView.setVisibility(View.GONE); }
From source file:com.btmura.android.reddit.app.AccountListActivity.java
private void setupViews(Bundle savedInstanceState) { ActionBar bar = getActionBar();/* ww w . ja va2s . c o m*/ if (bar != null) { bar.setDisplayHomeAsUpEnabled(true); } else { ViewStub vs = (ViewStub) findViewById(R.id.button_bar_stub); View buttonBar = vs.inflate(); addAccount = (Button) buttonBar.findViewById(R.id.ok); addAccount.setText(R.string.add_account); addAccount.setOnClickListener(this); View cancel = findViewById(R.id.cancel); cancel.setOnClickListener(this); } if (savedInstanceState == null) { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.replace(R.id.account_list_container, AccountListFragment.newInstance()); ft.commit(); } }
From source file:ro.expectations.expenses.ui.backup.FinancistoImportActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.app_bar);// ww w . j ava 2 s.c o m 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 ww w . j ava 2 s .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(); } }; }
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);/* w w w. ja v a 2 s .c om*/ } 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:com.linkedin.android.eventsapp.ProfileActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_profile); Bundle extras = getIntent() != null ? getIntent().getExtras() : new Bundle(); final Person person = extras.getParcelable("person"); final Activity currentActivity = this; final ActionBar bar = getActionBar(); View viewActionBar = getLayoutInflater().inflate(R.layout.layout_action_bar, null); ImageView backView = (ImageView) viewActionBar.findViewById(R.id.actionbar_left); backView.setImageResource(R.drawable.arrow_left); backView.setVisibility(View.VISIBLE); backView.setClickable(true);//from www . jav a2 s. c o m backView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { currentActivity.finish(); } }); ActionBar.LayoutParams params = new ActionBar.LayoutParams(ActionBar.LayoutParams.WRAP_CONTENT, ActionBar.LayoutParams.MATCH_PARENT); bar.setCustomView(viewActionBar, params); bar.setDisplayShowCustomEnabled(true); bar.setDisplayShowTitleEnabled(false); bar.setIcon(new ColorDrawable(Color.TRANSPARENT)); bar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#F15153"))); TextView attendeeNameView = (TextView) findViewById(R.id.attendeeName); attendeeNameView.setText(person.getFirstName() + " " + person.getLastName()); final ImageView attendeeImageView = (ImageView) findViewById(R.id.attendeeImage); final TextView attendeeHeadlineView = (TextView) findViewById(R.id.attendeeHeadline); final TextView attendeeLocationView = (TextView) findViewById(R.id.attendeeLocation); boolean isAccessTokenValid = LISessionManager.getInstance(currentActivity).getSession().isValid(); if (isAccessTokenValid) { String url = Constants.personByIdBaseUrl + person.getLinkedinId() + Constants.personProjection; APIHelper.getInstance(currentActivity).getRequest(currentActivity, url, new ApiListener() { @Override public void onApiSuccess(ApiResponse apiResponse) { try { JSONObject s = apiResponse.getResponseDataAsJson(); String headline = s.has("headline") ? s.getString("headline") : ""; String pictureUrl = s.has("pictureUrl") ? s.getString("pictureUrl") : null; JSONObject location = s.getJSONObject("location"); String locationName = location != null && location.has("name") ? location.getString("name") : ""; attendeeHeadlineView.setText(headline); attendeeLocationView.setText(locationName); if (pictureUrl != null) { new FetchImageTask(attendeeImageView).execute(pictureUrl); } else { attendeeImageView.setImageResource(R.drawable.ghost_person); } } catch (JSONException e) { } } @Override public void onApiError(LIApiError apiError) { } }); ViewStub viewOnLIStub = (ViewStub) findViewById(R.id.viewOnLIStub); View viewOnLI = viewOnLIStub.inflate(); Button viewOnLIButton = (Button) viewOnLI.findViewById(R.id.viewOnLinkedInButton); viewOnLIButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { DeepLinkHelper.getInstance().openOtherProfile(currentActivity, person.getLinkedinId(), new DeepLinkListener() { @Override public void onDeepLinkSuccess() { } @Override public void onDeepLinkError(LIDeepLinkError error) { } }); } }); } else { attendeeImageView.setImageResource(R.drawable.ghost_person); } }
From source file:org.mozilla.search.PreSearchFragment.java
private void updateUiFromCursor(Cursor c) { if (c != null && c.getCount() > 0) { return;/*from ww w . j av a 2 s .c o m*/ } if (emptyView == null) { final ViewStub emptyViewStub = (ViewStub) getView().findViewById(R.id.empty_view_stub); emptyView = emptyViewStub.inflate(); ((ImageView) emptyView.findViewById(R.id.empty_image)) .setImageResource(R.drawable.icon_search_empty_firefox); ((TextView) emptyView.findViewById(R.id.empty_title)).setText(R.string.search_empty_title); ((TextView) emptyView.findViewById(R.id.empty_message)).setText(R.string.search_empty_message); listView.setEmptyView(emptyView); } }
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())); }// www.ja va 2 s .co 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.teamltt.carcare.activity.BaseActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (includeDrawer) { setContentView(R.layout.activity_base); } else {//ww w .j a v a 2s .c o 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(); }