List of usage examples for android.text SpannableStringBuilder setSpan
public void setSpan(Object what, int start, int end, int flags)
From source file:com.vuze.android.remote.adapter.SideFilterAdapter.java
@Override public void onBindFlexibleViewHolder(SideFilterViewHolder holder, int position) { SideFilterInfo item = getItem(position); if (item.letters.equals(TorrentListFragment.LETTERS_BS)) { ImageSpan imageSpan = new ImageSpan(context, R.drawable.ic_backspace_white_24dp, DynamicDrawableSpan.ALIGN_BOTTOM); SpannableStringBuilder ss = new SpannableStringBuilder(","); ss.setSpan(imageSpan, 0, 1, 0); holder.tvText.setText(ss);/*www . ja v a 2 s .co m*/ } else { holder.tvText.setText(item.letters); int resID = item.letters.length() > 1 ? android.R.style.TextAppearance_Small : android.R.style.TextAppearance_Large; holder.tvText.setTextAppearance(context, resID); holder.tvText.setTextColor(ContextCompat.getColor(context, R.color.login_text_color)); } holder.tvCount.setText(item.count > 0 ? String.valueOf(item.count) : ""); }
From source file:com.irccloud.android.fragment.TextListFragment.java
private void setText(String text) { SpannableStringBuilder sb = new SpannableStringBuilder(text); for (int i = 0; i < 100; i++) sb.setSpan(new TabStopSpan.Standard(i * 300), 0, sb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); textView.setText(sb, TextView.BufferType.SPANNABLE); }
From source file:com.robomorphine.fragment.AboutDialogFragment.java
private CharSequence linkify(String text, String link) { SpannableStringBuilder builder = new SpannableStringBuilder(); URLSpan span = new URLSpan(link); builder.append(text);//from w ww . j a v a 2 s. co m builder.setSpan(span, 0, builder.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE); return builder; }
From source file:map.IconGeneratorDemoActivity.java
private CharSequence makeCharSequence() { String prefix = "Mixing "; String suffix = "different fonts"; String sequence = prefix + suffix; SpannableStringBuilder ssb = new SpannableStringBuilder(sequence); ssb.setSpan(new StyleSpan(ITALIC), 0, prefix.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); ssb.setSpan(new StyleSpan(BOLD), prefix.length(), sequence.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); return ssb;/*from ww w . j a va 2s. c o m*/ }
From source file:com.liferay.mobile.screens.viewsets.westeros.auth.signup.SignUpView.java
private void initClickableTermsAndConditions() { TextView textView = (TextView) findViewById(R.id.terms); textView.setMovementMethod(LinkMovementMethod.getInstance()); SpannableStringBuilder ssb = new SpannableStringBuilder("I accept the terms and conditions"); ssb.setSpan(new ClickableSpan() { @Override//from w ww . j av a 2 s . c om public void onClick(View widget) { SignUpScreenlet signUpScreenlet = getSignUpScreenlet(); signUpScreenlet.performUserAction(SignUpScreenlet.TERMS_AND_CONDITIONS); } }, 13, ssb.length(), 0); ssb.setSpan(new StyleSpan(Typeface.BOLD), 13, ssb.length(), 0); ssb.setSpan(new ForegroundColorSpan(ContextCompat.getColor(getContext(), android.R.color.white)), 13, ssb.length(), 0); textView.setText(ssb, TextView.BufferType.SPANNABLE); }
From source file:com.yek.keyboard.ui.settings.AboutAnySoftKeyboardFragment.java
@Override public void onViewStateRestored(Bundle savedInstanceState) { super.onViewStateRestored(savedInstanceState); TextView additionalSoftware = (TextView) getView().findViewById(R.id.about_legal_stuff_link); SpannableStringBuilder sb = new SpannableStringBuilder(additionalSoftware.getText()); sb.clearSpans();//removing any previously (from instance-state) set click spans. sb.setSpan(new ClickableSpan() { @Override//w w w . j a v a 2 s.com public void onClick(View widget) { FragmentChauffeurActivity activity = (FragmentChauffeurActivity) getActivity(); activity.addFragmentToUi(new AdditionalSoftwareLicensesFragment(), TransitionExperiences.DEEPER_EXPERIENCE_TRANSITION); } }, 0, additionalSoftware.getText().length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE); additionalSoftware.setMovementMethod(LinkMovementMethod.getInstance()); additionalSoftware.setText(sb); }
From source file:de.azapps.mirakel.new_ui.adapter.AutoCompleteAdapter.java
@Override public void bindView(View view, Context context, Cursor cursor) { final AutocompleteViewHolder viewHolder = (AutocompleteViewHolder) view.getTag(); final SearchObject searchObject = new SearchObject(cursor); // This is ok for tasks and a fallback variant for tags viewHolder.taskName.setText(searchObject.getName()); switch (searchObject.getAutocompleteType()) { case TASK://from w w w .j a v a 2s. co m if (searchObject.isDone()) { viewHolder.taskName .setPaintFlags(viewHolder.taskName.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); } else { viewHolder.taskName .setPaintFlags(viewHolder.taskName.getPaintFlags() & ~Paint.STRIKE_THRU_TEXT_FLAG); } break; case TAG: final Tag tag = new Tag(searchObject.getObjId(), searchObject.getName(), searchObject.getBackgroundColor(), false); TagSpan tagSpan = new TagSpan(tag, context); SpannableStringBuilder stringBuilder = new SpannableStringBuilder(); stringBuilder.append(new SpannableString(tag.getName())); stringBuilder.setSpan(tagSpan, 0, tag.getName().length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); viewHolder.taskName.setText(stringBuilder, TextView.BufferType.SPANNABLE); break; } }
From source file:com.abcs.haiwaigou.yyg.view.ReadMoreTextView.java
private CharSequence addClickableSpan(SpannableStringBuilder s, CharSequence trimText) { s.setSpan(viewMoreSpan, s.length() - trimText.length(), s.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); return s;/*from ww w. jav a 2 s .c o m*/ }
From source file:com.innoc.secureline.ui.UpgradeCallDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { final AlertDialog.Builder builder; if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB) { builder = new AlertDialog.Builder( new ContextThemeWrapper(getActivity(), R.style.RedPhone_Light_Dialog)); } else {/* www . j a v a 2 s .c om*/ builder = new AlertDialog.Builder(getActivity(), R.style.RedPhone_Light_Dialog); } builder.setIcon(R.drawable.red_call); final String upgradeString = getActivity().getResources() .getString(R.string.RedPhoneChooser_upgrade_to_redphone); SpannableStringBuilder titleBuilder = new SpannableStringBuilder(upgradeString); titleBuilder.setSpan(new AbsoluteSizeSpan(20, true), 0, upgradeString.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE); builder.setTitle(titleBuilder); //builder.setMessage(R.string.RedPhoneChooser_this_contact_also_uses_redphone_would_you_like_to_upgrade_to_a_secure_call); builder.setPositiveButton(R.string.RedPhoneChooser_secure_call, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(getActivity(), SecureLineService.class); intent.setAction(SecureLineService.ACTION_OUTGOING_CALL); intent.putExtra(Constants.REMOTE_NUMBER, number); getActivity().startService(intent); Intent activityIntent = new Intent(); activityIntent.setClass(getActivity(), SecureLine.class); activityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(activityIntent); getActivity().finish(); } }); builder.setNegativeButton(R.string.RedPhoneChooser_insecure_call, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { CallChooserCache.getInstance().addInsecureChoice(number); Intent intent = new Intent("android.intent.action.CALL", Uri.fromParts("tel", number + CallListener.IGNORE_SUFFIX, null)); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); getActivity().finish(); } }); AlertDialog alert = builder.create(); alert.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { ((AlertDialog) dialog).setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialogInterface) { getActivity().finish(); } }); ((AlertDialog) dialog).setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialogInterface) { getActivity().finish(); } }); Button positiveButton = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE); Button negativeButton = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_NEGATIVE); } }); return alert; }
From source file:com.mindprotectionkit.freephone.ui.UpgradeCallDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { final AlertDialog.Builder builder; if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB) { builder = new AlertDialog.Builder( new ContextThemeWrapper(getActivity(), R.style.RedPhone_Light_Dialog)); } else {//from w ww. java 2 s . c om builder = new AlertDialog.Builder(getActivity(), R.style.RedPhone_Light_Dialog); } builder.setIcon(R.drawable.red_call); final String upgradeString = getActivity().getResources() .getString(R.string.RedPhoneChooser_upgrade_to_redphone); SpannableStringBuilder titleBuilder = new SpannableStringBuilder(upgradeString); titleBuilder.setSpan(new AbsoluteSizeSpan(20, true), 0, upgradeString.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE); builder.setTitle(titleBuilder); //builder.setMessage(R.string.RedPhoneChooser_this_contact_also_uses_redphone_would_you_like_to_upgrade_to_a_secure_call); builder.setPositiveButton(R.string.RedPhoneChooser_secure_call, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(getActivity(), RedPhoneService.class); intent.setAction(RedPhoneService.ACTION_OUTGOING_CALL); intent.putExtra(Constants.REMOTE_NUMBER, number); getActivity().startService(intent); Intent activityIntent = new Intent(); activityIntent.setClass(getActivity(), RedPhone.class); activityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(activityIntent); getActivity().finish(); } }); builder.setNegativeButton(R.string.RedPhoneChooser_insecure_call, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { CallChooserCache.getInstance().addInsecureChoice(number); Intent intent = new Intent("android.intent.action.CALL", Uri.fromParts("tel", number + CallListener.IGNORE_SUFFIX, null)); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); getActivity().finish(); } }); AlertDialog alert = builder.create(); alert.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { ((AlertDialog) dialog).setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialogInterface) { getActivity().finish(); } }); ((AlertDialog) dialog).setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialogInterface) { getActivity().finish(); } }); Button positiveButton = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE); Button negativeButton = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_NEGATIVE); } }); return alert; }