List of usage examples for android.view ViewStub inflate
public View inflate()
From source file:org.mozilla.gecko.home.RecentTabsPanel.java
private void updateUiFromCursor(Cursor c) { if (c != null && c.getCount() > 0) { return;// w ww . j a v a 2s . co m } if (mEmptyView == null) { // Set empty panel view. We delay this so that the empty view won't flash. final ViewStub emptyViewStub = (ViewStub) getView().findViewById(R.id.home_empty_view_stub); mEmptyView = emptyViewStub.inflate(); final ImageView emptyIcon = (ImageView) mEmptyView.findViewById(R.id.home_empty_image); emptyIcon.setImageResource(R.drawable.icon_remote_tabs_empty); final TextView emptyText = (TextView) mEmptyView.findViewById(R.id.home_empty_text); emptyText.setText(R.string.home_last_tabs_empty); mList.setEmptyView(mEmptyView); } }
From source file:eu.vranckaert.worktime.utils.donations.DonationsFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); /* Flattr *//* ww w .j a va 2 s . c om*/ if (DonationsUtils.getResourceBoolean(getActivity(), "donations__flattr_enabled")) { // inflate flattr view into stub ViewStub flattrViewStub = (ViewStub) getActivity().findViewById(R.id.donations__flattr_stub); flattrViewStub.inflate(); buildFlattrView(); } /* Google */ mGoogleEnabled = DonationsUtils.getResourceBoolean(getActivity(), "donations__google_enabled"); if (mGoogleEnabled) { // inflate google view into stub ViewStub googleViewStub = (ViewStub) getActivity().findViewById(R.id.donations__google_stub); googleViewStub.inflate(); // get catalog from xml config CATALOG = DonationsUtils.getResourceStringArray(getActivity(), "donations__google_catalog"); // choose donation amount mGoogleSpinner = (Spinner) getActivity().findViewById(R.id.donations__google_android_market_spinner); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity(), R.array.donations__google_android_market_promt_array, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mGoogleSpinner.setAdapter(adapter); mHandler = new Handler(); mDonatePurchaseObserver = new DonatePurchaseObserver(mHandler); mBillingService = new BillingService(); mBillingService.setContext(getActivity()); Button btGoogle = (Button) getActivity() .findViewById(R.id.donations__google_android_market_donate_button); btGoogle.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { donateGoogleOnClick(v); } }); } /* PayPal */ if (DonationsUtils.getResourceBoolean(getActivity(), "donations__paypal_enabled")) { // inflate paypal view into stub ViewStub paypalViewStub = (ViewStub) getActivity().findViewById(R.id.donations__paypal_stub); paypalViewStub.inflate(); Button btPayPal = (Button) getActivity().findViewById(R.id.donations__paypal_donate_button); btPayPal.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { donatePayPalOnClick(v); } }); } }
From source file:net.naonedbus.fragment.CustomCursorFragment.java
/** * Afficher un message avec une desciption et un symbole. * //from w w w.j a va 2 s . co m * @param title * Le titre. * @param description * La description. * @param drawableRes * L'identifiant du symbole. */ protected void showMessage(final String title, final String description, final int drawableRes) { mFragmentView.findViewById(android.R.id.list).setVisibility(View.GONE); mFragmentView.findViewById(R.id.fragmentLoading).setVisibility(View.GONE); View message = mFragmentView.findViewById(R.id.fragmentMessage); if (message == null) { final ViewStub messageStrub = (ViewStub) mFragmentView.findViewById(R.id.fragmentMessageStub); message = messageStrub.inflate(); } message.setVisibility(View.VISIBLE); final TextView titleView = (TextView) message.findViewById(android.R.id.title); titleView.setText(title); titleView.setCompoundDrawablesWithIntrinsicBounds(0, drawableRes, 0, 0); final TextView descriptionView = (TextView) message.findViewById(android.R.id.summary); if (description != null) { descriptionView.setText(description); descriptionView.setVisibility(View.VISIBLE); } else { descriptionView.setVisibility(View.GONE); } }
From source file:com.achep.base.ui.DialogBuilder.java
/** * Builds dialog's view/*from ww w . j a v a2 s . c o m*/ * * @throws IllegalArgumentException when type is not one of defined. * @see #LAYOUT_COMMON * @see #LAYOUT_SKELETON */ public View createView(int type) { LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); ViewGroup rootLayout = (ViewGroup) createSkeleton(); ViewGroup contentLayout = rootLayout; switch (type) { case LAYOUT_COMMON: final boolean hasMessageOnly = mView == null && mViewRes == 0; final int layoutResource = mContentViewRes != 0 ? mContentViewRes : hasMessageOnly ? R.layout.dialog_message : R.layout.dialog_content; ViewStub viewStub = (ViewStub) inflater.inflate(R.layout.dialog_main_body, rootLayout, true) .findViewById(R.id.placeholder); viewStub.setLayoutResource(layoutResource); contentLayout = (ViewGroup) viewStub.inflate().findViewById(R.id.content); if (contentLayout == null) contentLayout = rootLayout; TextView messageView = (TextView) contentLayout.findViewById(R.id.message); if (messageView != null) { if (!TextUtils.isEmpty(mMessageText)) { messageView.setMovementMethod(new LinkMovementMethod()); messageView.setText(mMessageText); } else { ViewGroup vg = (ViewGroup) messageView.getParent(); vg.removeView(messageView); } } // Fall down. case LAYOUT_SKELETON: if (mViewRes != 0) { inflater.inflate(mViewRes, contentLayout, true); } else if (mView != null) { contentLayout.addView(mView); } return rootLayout; default: throw new IllegalArgumentException(); } }
From source file:bander.notepad.NoteListAppCompat.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Notepad.setAppCompatThemeFromPreferences(this, "NoteList"); SharedPreferences mSettings = PreferenceManager.getDefaultSharedPreferences(this); setContentView(R.layout.list_appcompat); ViewStub stub = (ViewStub) findViewById(R.id.toolbarWrapper); if (mSettings.getBoolean("darkAppCompatTheme", false)) stub.setLayoutResource(R.layout.toolbar_dark); else/* www.jav a 2 s . co m*/ stub.setLayoutResource(R.layout.toolbar_light); stub.inflate(); toolbar = (Toolbar) findViewById(R.id.toolbar); Notepad.setToolbarColor(this); setSupportActionBar(toolbar); Intent intent = getIntent(); if (intent.getData() == null) { intent.setData(Note.CONTENT_URI); } registerForContextMenu(getListView()); }
From source file:org.mozilla.gecko.home.HistoryPanel.java
private void updateUiFromCursor(Cursor c) { if (c != null && c.getCount() > 0) { if (RestrictedProfiles.isAllowed(getActivity(), Restriction.DISALLOW_CLEAR_HISTORY)) { mClearHistoryButton.setVisibility(View.VISIBLE); }/* w ww .j av a 2 s . co m*/ return; } // Cursor is empty, so hide the "Clear browsing history" button, // and set the empty view if it hasn't been set already. mClearHistoryButton.setVisibility(View.GONE); if (mEmptyView == null) { // Set empty panel view. We delay this so that the empty view won't flash. final ViewStub emptyViewStub = (ViewStub) getView().findViewById(R.id.home_empty_view_stub); mEmptyView = emptyViewStub.inflate(); final ImageView emptyIcon = (ImageView) mEmptyView.findViewById(R.id.home_empty_image); emptyIcon.setImageResource(R.drawable.icon_most_recent_empty); final TextView emptyText = (TextView) mEmptyView.findViewById(R.id.home_empty_text); emptyText.setText(R.string.home_most_recent_empty); final TextView emptyHint = (TextView) mEmptyView.findViewById(R.id.home_empty_hint); final String hintText = getResources().getString(R.string.home_most_recent_emptyhint); final SpannableStringBuilder hintBuilder = formatHintText(hintText); if (hintBuilder != null) { emptyHint.setText(hintBuilder); emptyHint.setMovementMethod(LinkMovementMethod.getInstance()); emptyHint.setVisibility(View.VISIBLE); } mList.setEmptyView(mEmptyView); } }
From source file:donations.DonationsFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); /* Flattr *//*from w w w . j a v a2 s . co m*/ if (mFlattrEnabled) { // inflate flattr view into stub ViewStub flattrViewStub = (ViewStub) getActivity().findViewById(R.id.donations__flattr_stub); flattrViewStub.inflate(); buildFlattrView(); } /* Google */ if (mGoogleEnabled) { // inflate google view into stub ViewStub googleViewStub = (ViewStub) getActivity().findViewById(R.id.donations__google_stub); googleViewStub.inflate(); // choose donation amount mGoogleSpinner = (Spinner) getActivity().findViewById(R.id.donations__google_android_market_spinner); ArrayAdapter<CharSequence> adapter; if (mDebug) { adapter = new ArrayAdapter<CharSequence>(getActivity(), android.R.layout.simple_spinner_item, CATALOG_DEBUG); } else { adapter = new ArrayAdapter<CharSequence>(getActivity(), android.R.layout.simple_spinner_item, mGoogleCatalogValues); } adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mGoogleSpinner.setAdapter(adapter); Button btGoogle = (Button) getActivity() .findViewById(R.id.donations__google_android_market_donate_button); btGoogle.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { donateGoogleOnClick(v); } }); // Create the helper, passing it our context and the public key to verify signatures with if (mDebug) Log.d(TAG, "Creating IAB helper."); mHelper = new IabHelper(getActivity(), mGooglePubkey); // enable debug logging (for a production application, you should set this to false). mHelper.enableDebugLogging(mDebug); // Start setup. This is asynchronous and the specified listener // will be called once setup completes. if (mDebug) Log.d(TAG, "Starting setup."); mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() { public void onIabSetupFinished(IabResult result) { if (mDebug) Log.d(TAG, "Setup finished."); if (!result.isSuccess()) { // Oh noes, there was a problem. openDialog(android.R.drawable.ic_dialog_alert, R.string.donations__google_android_market_not_supported_title, getString(R.string.donations__google_android_market_not_supported)); return; } // Have we been disposed of in the meantime? If so, quit. if (mHelper == null) return; } }); } /* PayPal */ if (mPaypalEnabled) { // inflate paypal view into stub ViewStub paypalViewStub = (ViewStub) getActivity().findViewById(R.id.donations__paypal_stub); paypalViewStub.inflate(); Button btPayPal = (Button) getActivity().findViewById(R.id.donations__paypal_donate_button); btPayPal.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { donatePayPalOnClick(v); } }); } }
From source file:com.hannesdorfmann.home.HomeActivity.java
private void showErrorView(boolean display) { if (display) { if (errorView == null) { ViewStub stub = (ViewStub) findViewById(R.id.stub_no_connection); errorView = (ImageView) stub.inflate(); final AnimatedVectorDrawable avd = (AnimatedVectorDrawable) getDrawable( R.drawable.avd_no_connection); errorView.setImageDrawable(avd); avd.start();/*from www.j a v a2 s . c o m*/ } errorView.setVisibility(View.VISIBLE); } else { if (errorView != null) { errorView.setVisibility(View.GONE); } } }
From source file:com.zion.htf.ui.fragment.ArtistSoundcloudFragment.java
private void setErrorMessage(String message) { ProgressBar progressBar = (ProgressBar) this.view.findViewById(R.id.progressBar); progressBar.setVisibility(0 == message.length() ? View.VISIBLE : View.GONE); TextView messageTextView = (TextView) this.view.findViewById(R.id.message); if (null == messageTextView) { ViewStub stub = (ViewStub) this.view.findViewById(R.id.empty_view_stub); if (null != stub) stub.inflate(); messageTextView = (TextView) this.view.findViewById(R.id.message); }/* w ww. j ava 2 s . c om*/ messageTextView.setVisibility(View.VISIBLE); messageTextView.setText(message); }
From source file:bander.notepad.NoteEditAppCompat.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Setting the theme Notepad.setAppCompatThemeFromPreferences(this, "Edit"); if (savedInstanceState != null) { final Object note = savedInstanceState.get(ORIGINAL_NOTE); if (note != null) mOriginalNote = (Note) note; }/*from w w w .jav a 2s .c o m*/ final Intent intent = getIntent(); final String action = intent.getAction(); if (Intent.ACTION_VIEW.equals(action) || Intent.ACTION_EDIT.equals(action)) { mState = STATE_EDIT; mUri = intent.getData(); } else if (Intent.ACTION_INSERT.equals(action)) { mState = STATE_INSERT; if (mOriginalNote == null) { mUri = getContentResolver().insert(intent.getData(), null); } else { mUri = mOriginalNote.getUri(); } setResult(RESULT_OK, (new Intent()).setAction(mUri.toString())); } if (mUri == null) { finish(); return; } { setContentView(R.layout.edit_appcompat); SharedPreferences mSettings = PreferenceManager.getDefaultSharedPreferences(this); ViewStub stub = (ViewStub) findViewById(R.id.toolbarWrapper); if (mSettings.getBoolean("darkAppCompatTheme", false)) stub.setLayoutResource(R.layout.toolbar_dark); else 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); mBodyText = (EditText) findViewById(R.id.body); } }