List of usage examples for android.text SpannableString setSpan
public void setSpan(Object what, int start, int end, int flags)
From source file:eltos.simpledialogfragments.FlatFragmentActivity.java
/** * Let the hosting fragment or activity implement this interface * to receive results from the dialog// w w w .j a va2s . co m * * @param dialogTag the tag passed to {@link SimpleDialog#show} * @param which result type, one of {@link #BUTTON_POSITIVE}, {@link #BUTTON_NEGATIVE}, * {@link #BUTTON_NEUTRAL} or {@link #CANCELED} * @param extras the extras passed to {@link SimpleDialog#extra(Bundle)} * @return true if the result was handled, false otherwise */ @Override public boolean onResult(@NonNull String dialogTag, int which, @NonNull Bundle extras) { // handle results as usual if (COLOR_FRAGMENT.equals(dialogTag) && which == BUTTON_POSITIVE) { @ColorInt int color = extras.getInt(SimpleColorDialog.COLOR); // Sets action bar colors if (getSupportActionBar() != null) { getSupportActionBar().setBackgroundDrawable(new ColorDrawable(0xFF000000 | color)); boolean dark = Color.red(color) * 0.299 + Color.green(color) * 0.587 + Color.blue(color) * 0.114 < 180; SpannableString s = new SpannableString(getSupportActionBar().getTitle()); s.setSpan(new ForegroundColorSpan(dark ? Color.WHITE : Color.BLACK), 0, s.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); getSupportActionBar().setTitle(s); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { float[] hsv = new float[3]; Color.colorToHSV(color, hsv); hsv[2] *= 0.75; getWindow().setStatusBarColor(Color.HSVToColor(hsv)); } return true; } return false; }
From source file:com.flowzr.activity.EntityListActivity.java
public void setMyTitle(String t) { SpannableString s = new SpannableString(t); s.setSpan(new TypefaceSpan("sans-serif"), 0, s.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); getSupportActionBar().setTitle(s);//w w w. j a v a2 s. c o m }
From source file:li.barter.AbstractBarterLiActivity.java
protected final void setActionBarTitle(final String title) { final SpannableString s = new SpannableString(title); s.setSpan(new TypefacedSpan(this, TypefaceCache.ALEGREYA_BLACK_ITALIC), 0, s.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); // Update the action bar title with the TypefaceSpan instance final ActionBar actionBar = getActionBar(); actionBar.setTitle(s);// w w w.j a va 2 s . c o m }
From source file:com.groupme.sdk.activity.PinEntryActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_pinentry); TextView pinEntryInstructions = (TextView) findViewById(R.id.pin_entry_instructions); pinEntryInstructions// w w w .j av a2 s . co m .setText(getString(R.string.pin_entry_instructions, getIntent().getStringExtra("phone_number"))); mNameEntry = (EditText) findViewById(R.id.name_entry); mPinEntry = (EditText) findViewById(R.id.pin_entry); mAlternateButton = (Button) findViewById(R.id.not_number_button); SpannableString str = new SpannableString(getString(R.string.link_not_number)); str.setSpan(new UnderlineSpan(), 0, str.length(), 0); mAlternateButton.setText(str); }
From source file:eu.lucazanini.arpav.fragment.CreditsFragment.java
private SpannableString getTextWithLink(SpannableString text, String link, String site) { int start = text.toString().indexOf(link); int end = start + link.length(); text.setSpan(new URLSpan(site), start, end, 0); return text;// w w w .j a va2 s. c o m }
From source file:com.senior.fragments.ArticleContent.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { //Obtains each articleView = inflater.inflate(R.layout.articles_fragment, container, false); TextView title = (TextView) articleView.findViewById(R.id.title); progress = (ProgressBar) articleView.findViewById(R.id.progress); SpannableString NewTitle = new SpannableString(articleTitle); //Sets the options for display NewTitle.setSpan(new UnderlineSpan(), 0, NewTitle.length(), 0); title.setText(NewTitle);//from w w w . j av a 2s. c o m reloadButton = (Button) articleView.findViewById(R.id.refresh); reloadButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { refreshArticle(); } }); return articleView; }
From source file:cw.kop.autobackground.tutorial.AppFragment.java
private void resetFabricText(boolean use) { SpannableString text; if (use) {/*from www .j a v a2s .co m*/ text = new SpannableString("Thanks!"); text.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.BLUE_OPAQUE)), 0, text.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } else { text = new SpannableString("Send reports?"); } fabricText.setText(text); fabricText.invalidate(); }
From source file:com.liuwuping.sm.ui.user.UserActivity.java
private SpannableString newTabTitle(CharSequence old, int add) { int start = old.length(); String newStr = old.toString() + "\n" + add; CharSequence newCs = newStr;//from ww w . j ava2 s . c o m SpannableString ss = new SpannableString(newCs); ss.setSpan(new TextAppearanceSpan(this, R.style.TabTitleNum), start, newCs.length(), 0); return ss; }
From source file:com.andrada.sitracker.ui.fragment.AboutDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { PackageManager pm = getActivity().getPackageManager(); String packageName = getActivity().getPackageName(); String versionName;//w ww. j a v a 2s . com try { PackageInfo info = pm.getPackageInfo(packageName, 0); versionName = info.versionName; } catch (PackageManager.NameNotFoundException e) { versionName = VERSION_UNAVAILABLE; } SpannableStringBuilder aboutBody = new SpannableStringBuilder(); SpannableString licensesLink = new SpannableString(getString(R.string.about_licenses)); licensesLink.setSpan(new ClickableSpan() { @Override public void onClick(View view) { showOpenSourceLicenses(getActivity()); } }, 0, licensesLink.length(), 0); SpannableString whatsNewLink = new SpannableString(getString(R.string.whats_new)); whatsNewLink.setSpan(new ClickableSpan() { @Override public void onClick(View view) { showWhatsNew(getActivity()); } }, 0, whatsNewLink.length(), 0); aboutBody.append(licensesLink); aboutBody.append("\n\n"); aboutBody.append(whatsNewLink); AboutDialogView aboutBodyView = AboutDialogView_.build(getActivity()); aboutBodyView.bindData(getString(R.string.app_version_format, versionName), aboutBody); return new AlertDialog.Builder(getActivity()).setTitle(R.string.action_about).setView(aboutBodyView) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); } }).create(); }
From source file:com.senior.fragments.HomeFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Log.i("HomeFrag", "View Created"); view = inflater.inflate(R.layout.home_fragment, container, false); titletext = (TextView) view.findViewById(R.id.calenderevents); SpannableString NewTitle = new SpannableString("Calendar Of Events"); NewTitle.setSpan(new UnderlineSpan(), 0, NewTitle.length(), 0); titletext.setText(NewTitle);/*from www . j a v a 2 s . c o m*/ mListView = (ListView) view.findViewById(android.R.id.list); reloadButton = (Button) view.findViewById(R.id.refresh); reloadButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { getArticles(); } }); progress = (ProgressBar) view.findViewById(R.id.progress); return view; }