List of usage examples for android.widget TextView setVisibility
@RemotableViewMethod public void setVisibility(@Visibility int visibility)
From source file:com.DGSD.Teexter.UI.Recipient.RecipientAlternatesAdapter.java
@Override public void bindView(View view, Context context, Cursor cursor) { int position = cursor.getPosition(); TextView display = (TextView) view.findViewById(android.R.id.title); ImageView imageView = (ImageView) view.findViewById(android.R.id.icon); RecipientEntry entry = getRecipientEntry(position); if (position == 0) { display.setText(cursor.getString(EmailQuery.NAME)); display.setVisibility(View.VISIBLE); imageView.setImageURI(entry.getPhotoThumbnailUri()); imageView.setVisibility(View.VISIBLE); } else {//w w w . ja v a 2 s. co m display.setVisibility(View.GONE); imageView.setVisibility(View.GONE); } TextView destination = (TextView) view.findViewById(android.R.id.text1); destination.setText(cursor.getString(EmailQuery.ADDRESS)); TextView destinationType = (TextView) view.findViewById(android.R.id.text2); if (destinationType != null) { destinationType .setText(Email.getTypeLabel(context.getResources(), cursor.getInt(EmailQuery.ADDRESS_TYPE), cursor.getString(EmailQuery.ADDRESS_LABEL)).toString().toUpperCase()); } }
From source file:com.abcvoipsip.ui.calllog.CallLogDetailsFragment.java
/** Configures the call button area using the given entry. */ private void configureCallButton(String callText, CharSequence nbrLabel, CharSequence number) { View convertView = getView().findViewById(R.id.call_and_sms); convertView.setVisibility(TextUtils.isEmpty(number) ? View.GONE : View.VISIBLE); TextView text = (TextView) convertView.findViewById(R.id.call_and_sms_text); View mainAction = convertView.findViewById(R.id.call_and_sms_main_action); mainAction.setOnClickListener(mPrimaryActionListener); mainAction.setContentDescription(callText); mainAction.setTag(number);/* ww w . j a v a2 s . co m*/ text.setText(callText); TextView label = (TextView) convertView.findViewById(R.id.call_and_sms_label); if (TextUtils.isEmpty(nbrLabel)) { label.setVisibility(View.GONE); } else { label.setText(nbrLabel); label.setVisibility(View.VISIBLE); } }
From source file:com.brq.wallet.activity.main.BalanceFragment.java
private void setFiatValue(int textViewResourceId, CurrencyValue value, boolean hideOnZeroBalance) { TextView tv = (TextView) _root.findViewById(textViewResourceId); if (!_mbwManager.hasFiatCurrency() || _exchangeRatePrice == null || (hideOnZeroBalance && value.isZero()) || value.isFiat()) {/* www . j a va2s . c o m*/ tv.setVisibility(View.GONE); } else { try { long satoshis = value.getAsBitcoin(_mbwManager.getExchangeRateManager()).getLongValue(); tv.setVisibility(View.VISIBLE); String converted = Utils.getFiatValueAsString(satoshis, _exchangeRatePrice); String currency = _mbwManager.getFiatCurrency(); tv.setText(getResources().getString(R.string.approximate_fiat_value, currency, converted)); } catch (IllegalArgumentException ex) { // something failed while calculating the bitcoin amount tv.setVisibility(View.GONE); } } }
From source file:com.gh4a.fragment.RepositoryFragment.java
private void fillTextView(int id, int stringId, String text) { TextView view = (TextView) mContentView.findViewById(id); if (!StringUtils.isBlank(text)) { view.setText(stringId != 0 ? getString(stringId, text) : text); view.setVisibility(View.VISIBLE); } else {//from ww w .java 2s. c o m view.setVisibility(View.GONE); } }
From source file:com.silentcircle.silenttext.activity.AccountCreationActivity.java
@Override public void onError(final CharSequence message) { runOnUiThread(new Runnable() { @Override/*from w ww . j ava 2 s. c om*/ public void run() { TextView error = (TextView) findViewById(R.id.error); error.setText( message == null || message.length() <= 0 ? getString(R.string.error_unknown) : message); error.setVisibility(View.VISIBLE); error.startAnimation(AnimationUtils.loadAnimation(error.getContext(), R.anim.slide_down)); handler.removeCallbacks(hideError); handler.postDelayed(hideError, 5000); } }); }
From source file:com.afwsamples.testdpc.common.preference.DpcPreferenceHelper.java
/** * Override the summary with any constraint violation messages. *///from w w w . j a v a 2 s . c o m public void onBindViewHolder(PreferenceViewHolder holder) { if (!constraintsMet()) { final TextView summaryView = (TextView) holder.findViewById(android.R.id.summary); if (summaryView != null) { summaryView.setText(mConstraintViolationSummary); summaryView.setVisibility(View.VISIBLE); } } }
From source file:com.gh4a.fragment.UserFragment.java
public void fillTopRepos(Collection<Repository> topRepos) { LinearLayout ll = (LinearLayout) mContentView.findViewById(R.id.ll_top_repos); ll.removeAllViews();/*from w w w. j a va2 s . c o m*/ LayoutInflater inflater = getLayoutInflater(null); if (topRepos != null) { for (Repository repo : topRepos) { View rowView = inflater.inflate(R.layout.top_repo, null); rowView.setOnClickListener(this); rowView.setTag(repo); TextView tvTitle = (TextView) rowView.findViewById(R.id.tv_title); tvTitle.setText(repo.getOwner().getLogin() + "/" + repo.getName()); TextView tvDesc = (TextView) rowView.findViewById(R.id.tv_desc); if (!StringUtils.isBlank(repo.getDescription())) { tvDesc.setVisibility(View.VISIBLE); tvDesc.setText(repo.getDescription()); } else { tvDesc.setVisibility(View.GONE); } TextView tvForks = (TextView) rowView.findViewById(R.id.tv_forks); tvForks.setText(String.valueOf(repo.getForks())); TextView tvStars = (TextView) rowView.findViewById(R.id.tv_stars); tvStars.setText(String.valueOf(repo.getWatchers())); ll.addView(rowView); } } View btnMore = getView().findViewById(R.id.btn_repos); if (topRepos != null && !topRepos.isEmpty()) { btnMore.setOnClickListener(this); btnMore.setVisibility(View.VISIBLE); } else { TextView hintView = (TextView) inflater.inflate(R.layout.hint_view, ll, false); hintView.setText(R.string.user_no_repos); ll.addView(hintView); } getView().findViewById(R.id.pb_top_repos).setVisibility(View.GONE); getView().findViewById(R.id.ll_top_repos).setVisibility(View.VISIBLE); }
From source file:com.example.android.xyztouristattractions.ui.DetailFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { setHasOptionsMenu(true);/*from w w w . j a v a 2 s . c om*/ View view = inflater.inflate(R.layout.fragment_detail, container, false); String attractionName = getArguments().getString(EXTRA_ATTRACTION); mAttraction = findAttraction(attractionName); if (mAttraction == null) { getActivity().finish(); return null; } TextView nameTextView = (TextView) view.findViewById(R.id.nameTextView); TextView descTextView = (TextView) view.findViewById(R.id.descriptionTextView); TextView distanceTextView = (TextView) view.findViewById(R.id.distanceTextView); ImageView imageView = (ImageView) view.findViewById(R.id.imageView); LatLng location = Utils.getLocation(getActivity()); String distance = Utils.formatDistanceBetween(location, mAttraction.location); if (TextUtils.isEmpty(distance)) { distanceTextView.setVisibility(View.GONE); } nameTextView.setText(attractionName); distanceTextView.setText(distance); descTextView.setText(mAttraction.longDescription); int imageSize = getResources().getDimensionPixelSize(R.dimen.image_size) * Constants.IMAGE_ANIM_MULTIPLIER; Glide.with(getActivity()).load(mAttraction.imageUrl).diskCacheStrategy(DiskCacheStrategy.SOURCE) .placeholder(R.color.lighter_gray).override(imageSize, imageSize).into(imageView); return view; }
From source file:com.android.contacts.interactions.ImportDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { final LayoutInflater dialogInflater = (LayoutInflater) getContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); // Adapter that shows a list of string resources final ArrayAdapter<AdapterEntry> adapter = new ArrayAdapter<AdapterEntry>(getActivity(), R.layout.select_dialog_item) { @Override//from w w w.j ava 2s.c om public View getView(int position, View convertView, ViewGroup parent) { final View result = convertView != null ? convertView : dialogInflater.inflate(R.layout.select_dialog_item, parent, false); final TextView primaryText = (TextView) result.findViewById(R.id.primary_text); final TextView secondaryText = (TextView) result.findViewById(R.id.secondary_text); final AdapterEntry entry = getItem(position); secondaryText.setVisibility(View.GONE); if (entry.mChoiceResourceId == R.string.import_from_sim) { final CharSequence secondary = getSimSecondaryText(entry.mSim); if (TextUtils.isEmpty(secondary)) { secondaryText.setVisibility(View.GONE); } else { secondaryText.setText(secondary); secondaryText.setVisibility(View.VISIBLE); } } primaryText.setText(entry.mLabel); return result; } CharSequence getSimSecondaryText(SimCard sim) { int count = getSimContactCount(sim); CharSequence phone = sim.getFormattedPhone(); if (phone == null) { phone = sim.getPhone(); } if (phone != null) { phone = sBidiFormatter.unicodeWrap(PhoneNumberUtilsCompat.createTtsSpannable(phone), TextDirectionHeuristicsCompat.LTR); } if (count != -1 && phone != null) { // We use a template instead of format string so that the TTS span is preserved final CharSequence template = getResources() .getQuantityString(R.plurals.import_from_sim_secondary_template, count); return TextUtils.expandTemplate(template, String.valueOf(count), phone); } else if (phone != null) { return phone; } else if (count != -1) { // count != -1 return getResources().getQuantityString(R.plurals.import_from_sim_secondary_contact_count_fmt, count, count); } else { return null; } } }; addItems(adapter); final DialogInterface.OnClickListener clickListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { final int resId = adapter.getItem(which).mChoiceResourceId; if (resId == R.string.import_from_sim) { handleSimImportRequest(adapter.getItem(which).mSim); } else if (resId == R.string.import_from_vcf_file) { handleImportRequest(resId, SimCard.NO_SUBSCRIPTION_ID); } else { Log.e(TAG, "Unexpected resource: " + getActivity().getResources().getResourceEntryName(resId)); } dialog.dismiss(); } }; final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), getTheme()) .setTitle(R.string.dialog_import).setNegativeButton(android.R.string.cancel, null); if (adapter.isEmpty()) { // Handle edge case; e.g. SIM card was removed. builder.setMessage(R.string.nothing_to_import_message); } else { builder.setSingleChoiceItems(adapter, -1, clickListener); } return builder.create(); }
From source file:com.enadein.carlogbook.core.BaseActivity.java
protected boolean validateFuelVavlView(int errorViewId, EditText editView) { TextView errorView = (TextView) findViewById(errorViewId); double valueDouble = CommonUtils.getRawDouble((editView.getText().toString())); boolean result = valueDouble > 0.0009 && 1000.d >= valueDouble; errorView.setVisibility((!result) ? View.VISIBLE : View.GONE); return result; }