List of usage examples for android.text SpannableString SpannableString
public SpannableString(CharSequence source)
From source file:io.github.hidroh.materialistic.widget.preference.HelpListView.java
private Spannable makeAsteriskSpan() { SpannableString sb = new SpannableString("*"); sb.setSpan(new AsteriskSpan(getContext()), sb.length() - 1, sb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); return sb;/* w w w . j av a 2 s .c o m*/ }
From source file:tw.com.geminihsu.app01.fragment.Fragment_OrderFilter.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { MenuItem item = menu.add(Menu.NONE, ACTIONBAR_MENU_ITEM_FINISH, Menu.NONE, getString(R.string.btn_finish)); SpannableString spanString = new SpannableString(item.getTitle().toString()); spanString.setSpan(new ForegroundColorSpan(Color.WHITE), 0, spanString.length(), 0); //fix the color to white item.setTitle(spanString);//from w ww . j a va 2s. co m item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); super.onCreateOptionsMenu(menu, inflater); }
From source file:com.nineducks.hereader.HackfulReaderActivity.java
@Override protected Dialog onCreateDialog(int id) { Dialog result = null;// ww w . j a va2 s . c om AlertDialog.Builder builder = null; switch (id) { case R.id.open_dialog: builder = new AlertDialog.Builder(this); builder.setTitle(R.string.open_dialog_title); builder.setItems(R.array.open_dialog_options, (OnClickListener) itemsController); builder.setCancelable(true); result = builder.create(); break; case R.id.about_dialog: builder = new AlertDialog.Builder(this); builder.setTitle(R.string.about_dialog_title); ScrollView scroll = new ScrollView(this); TextView msg = new TextView(this); SpannableString s = new SpannableString(getString(R.string.about_dialog_text)); Linkify.addLinks(s, Linkify.WEB_URLS); msg.setText(s); msg.setMovementMethod(LinkMovementMethod.getInstance()); msg.setTextSize(16); msg.setPadding(15, 15, 15, 15); scroll.addView(msg); builder.setView(scroll); builder.setInverseBackgroundForced(true); result = builder.create(); break; } return result; }
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 w ww . j a v a 2s. co 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; }
From source file:cat.mvmike.minimalcalendarwidget.service.DayService.java
private static void setInstanceNumber(final Context context, final RemoteViews cellRv, final String dayOfMonth, final boolean isToday, final int found) { Symbol symbols = ConfigurationService.getInstancesSymbols(context); Character[] symbolArray = symbols.getArray(); int max = symbolArray.length - 1; String symbol = String.valueOf(found > max ? symbolArray[max] : symbolArray[found]); String dayOfMonthSpSt = PADDING + (dayOfMonth.length() == 1 ? dayOfMonth + DOUBLE_PADDING : dayOfMonth) + PADDING + symbol;//from w ww. ja va2 s . c o m SpannableString daySpSt = new SpannableString(dayOfMonthSpSt); daySpSt.setSpan(new StyleSpan(Typeface.BOLD), dayOfMonthSpSt.length() - 1, dayOfMonthSpSt.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); int color; if (isToday) { color = ContextCompat.getColor(context, R.color.instances_today); daySpSt.setSpan(new StyleSpan(Typeface.BOLD), 0, dayOfMonthSpSt.length() - 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } else { color = ContextCompat.getColor(context, ConfigurationService.getInstancesSymbolsColours(context).getHexValue()); } daySpSt.setSpan(new ForegroundColorSpan(color), dayOfMonthSpSt.length() - 1, dayOfMonthSpSt.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); daySpSt.setSpan(new RelativeSizeSpan(symbols.getRelativeSize()), dayOfMonthSpSt.length() - 1, dayOfMonthSpSt.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); cellRv.setTextViewText(android.R.id.text1, daySpSt); }
From source file:cw.kop.autobackground.tutorial.FinishFragment.java
@Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.tutorial_finish_fragment, container, false); int colorFilterInt = AppSettings.getColorFilterInt(appContext); TextView titleText = (TextView) view.findViewById(R.id.title_text); titleText.setTextColor(colorFilterInt); titleText.setText("That's it."); TextView tutorialText = (TextView) view.findViewById(R.id.tutorial_text); tutorialText.setTextColor(colorFilterInt); tutorialText.setText("Now you're ready to use AutoBackground. I'd suggest adding a new source first " + "and then hitting download." + "\n" + "\n" + "If you have any questions, concerns, suggestions, or whatever else, feel free to " + "email me at "); SpannableString emailString = new SpannableString("chiuwinson@gmail.com"); ClickableSpan clickableSpan = new ClickableSpan() { @Override// ww w. j a v a2 s.c o m public void onClick(View widget) { Log.i(TAG, "Clicked"); Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", "chiuwinson@gmail.com", null)); emailIntent.putExtra(Intent.EXTRA_SUBJECT, "AutoBackground Feedback"); startActivity(Intent.createChooser(emailIntent, "Send email")); } }; emailString.setSpan(clickableSpan, 0, emailString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); tutorialText.append(emailString); tutorialText.append("."); tutorialText.setMovementMethod(LinkMovementMethod.getInstance()); return view; }
From source file:fr.tvbarthel.apps.sayitfromthesky.activities.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ButterKnife.inject(this); mActionBarTitleColorSpan = new AlphaForegroundColorSpan(getResources().getColor(R.color.material_grey_300)); mActionBarTitleSpannable = new SpannableString(getString(R.string.app_name)); setActionBarTitleAlpha(1);//from ww w . j av a2s .co m // Compute the action bar size mActionBarSize = ActionBarHelper.getActionBarSize(this); // Set the height of the header container to 1/3.5 of the root height. ViewTreeObserver vto = mRootView.getViewTreeObserver(); if (vto.isAlive()) { vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { ViewHelper.removeOnGlobalLayoutListener(mRootView, this); final int headerHeight = (int) (mRootView.getHeight() / 3.5); mHeaderContainer.getLayoutParams().height = headerHeight; mListView.setPadding(0, headerHeight - mActionBarSize, 0, 0); final int actionBarLogoSize = getResources() .getDimensionPixelSize(R.dimen.action_bar_logo_size); final int actionBarMarginLeft = getResources() .getDimensionPixelOffset(R.dimen.action_bar_margin_left); mHeaderLogoMaxTranslationX = (mHeaderContainer.getWidth() - actionBarLogoSize) / 2 - actionBarMarginLeft; mHeaderLogoFinalScale = ((float) actionBarLogoSize) / mHeaderLogo.getWidth(); } }); } mDrawingAdapter = new DrawingAdapter(this); initListView(); getLoaderManager().initLoader(LOADER_ID_DRAWINGS, null, this); ViewHelper.slideFromBottom(mBtnNewDrawing); }
From source file:mobisocial.musubi.ui.util.EmojiSpannableFactory.java
@Override public Spannable newSpannable(CharSequence source) { if (source == null) { return null; }/*from w w w . j av a 2 s.co m*/ SpannableString span = new SpannableString(source); updateSpannable(span); return span; }
From source file:io.vit.vitio.Settings.SettingsActivity.java
private void setToolbar() { toolbar.setBackgroundColor(getResources().getColor(R.color.darkgray)); setSupportActionBar(toolbar);/*from w w w.j a v a 2s .c o m*/ SpannableString s = new SpannableString("SETTINGS"); myTheme.refreshTheme(); s.setSpan(myTheme.getMyThemeTypeFaceSpan(), 0, s.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); getSupportActionBar().setTitle(s); getSupportActionBar().setDisplayHomeAsUpEnabled(true); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { returnBack(); } }); changeStatusBarColor(getResources().getColor(R.color.darkergray)); }
From source file:com.handpoint.headstart.client.ui.LoginActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); HeadstartService.removeProperty("last_activity"); mPreferences = PreferenceManager.getDefaultSharedPreferences(this); long elapsedTime = SystemClock.elapsedRealtime(); long lastAttempt = getLastAttempt(); if (elapsedTime > lastAttempt && lastAttempt > 0 && lastAttempt + ATTEMPT_DELAY > elapsedTime) { long timeToWait = ATTEMPT_DELAY - (elapsedTime - lastAttempt); Toast.makeText(this, getString(R.string.warn_wait_message, formatTime(timeToWait)), Toast.LENGTH_LONG) .show();/*w ww . java2s . c o m*/ finish(); return; } setLastAttempt(0); setContentView(R.layout.login); Button loginButton = (Button) findViewById(R.id.login_button); loginButton.setOnClickListener(this); TextView forgotLink = (TextView) findViewById(R.id.forgot_password_link); SpannableString content = new SpannableString(getString(R.string.forgot_password_link_label)); content.setSpan(new UnderlineSpan(), 0, content.length(), 0); forgotLink.setText(content); forgotLink.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { DialogFragment newFragment = new ForgotPasscodeDialog(); newFragment.show(getSupportFragmentManager(), "forgot_passcode"); } }); }