List of usage examples for android.text.style UnderlineSpan UnderlineSpan
public UnderlineSpan()
From source file:Main.java
public static Spannable createUnderline(String str) { SpannableString contentUnderline = new SpannableString(str); contentUnderline.setSpan(new UnderlineSpan(), 0, contentUnderline.length(), 0); return contentUnderline; }
From source file:Main.java
public static void setUnderLine(TextView tv) { if (tv.getText() != null) { String udata = tv.getText().toString(); SpannableString content = new SpannableString(udata); content.setSpan(new UnderlineSpan(), 0, udata.length(), 0); tv.setText(content);/* w ww. ja va2 s . c om*/ content.setSpan(new UnderlineSpan(), 0, udata.length(), 0); } else { tv.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG); } }
From source file:Main.java
public static SpannableString setTextUnderline(String content, int startIndex, int endIndex) { if (TextUtils.isEmpty(content) || startIndex < 0 || endIndex >= content.length() || startIndex >= endIndex) { return null; }/*from w ww . ja v a2 s. co m*/ SpannableString spannableString = new SpannableString(content); spannableString.setSpan(new UnderlineSpan(), startIndex, endIndex, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); return spannableString; }
From source file:com.nasageek.utexasutilities.activities.AboutMeActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.aboutme_layout); actionbar = getSupportActionBar();//from www. j a v a2s .c o m actionbar.setTitle("About"); actionbar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); actionbar.setHomeButtonEnabled(true); actionbar.setDisplayHomeAsUpEnabled(true); // force the License Dialog link to be underlined so it looks "linky" TextView licenseView = (TextView) findViewById(R.id.library_license_link); SpannableString underlinedLicenseLink = new SpannableString(getString(R.string.library_license_link)); underlinedLicenseLink.setSpan(new UnderlineSpan(), 0, underlinedLicenseLink.length(), 0); licenseView.setText(underlinedLicenseLink); licenseView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { FragmentManager fm = getSupportFragmentManager(); LibraryLicenseDialog libraryLicenseDlg = new LibraryLicenseDialog(); libraryLicenseDlg.show(fm, "fragment_license"); } }); // do the same thing with the Privacy Policy link TextView policyView = (TextView) findViewById(R.id.privacy_policy_link); SpannableString underlinedPolicyLink = new SpannableString(getString(R.string.privacy_policy_link)); underlinedPolicyLink.setSpan(new UnderlineSpan(), 0, underlinedPolicyLink.length(), 0); policyView.setText(underlinedPolicyLink); policyView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { FragmentManager fm = getSupportFragmentManager(); PrivacyPolicyDialog privacyPolicyDlg = new PrivacyPolicyDialog(); privacyPolicyDlg.show(fm, "fragment_privacy_policy"); } }); TextView versionNumberView = (TextView) findViewById(R.id.version); String versionName = ""; try { versionName = getPackageManager().getPackageInfo(getPackageName(), 0).versionName; } catch (NameNotFoundException e) { // of course UTilities is installed... e.printStackTrace(); } versionNumberView.setText(versionName); }
From source file:Main.java
/** * Returns the bulleted list based on the given {@code lines}. * If one of lines starts with {@link BulletListUtil#BAD_FIRST_SYMBOLS}, then such symbol is * removed from there (sometimes bad lines are received from the Food2Work). * Also if line consists of the upper case words, then this line is used like a header and is * underlined.//from ww w .j a v a 2 s . co m * * @param leadingMargin In pixels, the space between the left edge of the bullet and the left * edge of the text * @param lines List of strings. Each string will be a separate item in the bulleted list * @return The bulleted list based on the given {@code lines} */ public static CharSequence makeBulletList(List<String> lines, int leadingMargin) { List<Spanned> spanned = new ArrayList<>(lines.size()); for (String line : lines) { if (!line.trim().isEmpty()) { Spanned spannedLine = Html.fromHtml(removeBadFirstCharacters(line.trim())); spanned.add(spannedLine); } } SpannableStringBuilder sb = new SpannableStringBuilder(); for (int i = 0; i < spanned.size(); i++) { CharSequence line = spanned.get(i) + (i < spanned.size() - 1 ? "\n" : ""); boolean underlineNeeded = isUpperCase(line); Spannable spannable = new SpannableString(line); if (underlineNeeded) { spannable.setSpan(new UnderlineSpan(), 0, spannable.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE); } else { spannable.setSpan(new BulletSpan(leadingMargin), 0, spannable.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE); } sb.append(spannable); } return sb; }
From source file:typical_if.android.fragment.FragmentAboutUs.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_about, container, false); setRetainInstance(true);// w w w . j av a2 s . c om final ImageView devLight = (ImageView) rootView.findViewById(R.id.DevLightBtn); final ImageView stantsiya = (ImageView) rootView.findViewById(R.id.stantsiya); final ImageView tf = (ImageView) rootView.findViewById(R.id.tf_site); final TextView viktor = (TextView) rootView.findViewById(R.id.viktor_ref); final SpannableString content = new SpannableString(viktor.getText()); content.setSpan(new UnderlineSpan(), 0, viktor.length(), 0); viktor.setText(content); final TextView yura = (TextView) rootView.findViewById(R.id.yurij_ref); final SpannableString content1 = new SpannableString(yura.getText()); content1.setSpan(new UnderlineSpan(), 0, yura.length(), 0); yura.setText(content1); final TextView lyubomir = (TextView) rootView.findViewById(R.id.lyubomir_ref); final SpannableString content2 = new SpannableString(lyubomir.getText()); content2.setSpan(new UnderlineSpan(), 0, lyubomir.length(), 0); lyubomir.setText(content2); final TextView vasil = (TextView) rootView.findViewById(R.id.vasil_ref); final SpannableString content3 = new SpannableString(vasil.getText()); content3.setSpan(new UnderlineSpan(), 0, vasil.length(), 0); vasil.setText(content3); final TextView our_site_ref = (TextView) rootView.findViewById(R.id.devlight_com_ua_ref); final SpannableString content4 = new SpannableString(our_site_ref.getText()); content4.setSpan(new UnderlineSpan(), 0, our_site_ref.length(), 0); our_site_ref.setText(content4); final TextView goToLicensePage = (TextView) rootView.findViewById(R.id.go_to_license); final SpannableString content5 = new SpannableString(goToLicensePage.getText()); content5.setSpan(new UnderlineSpan(), 0, goToLicensePage.length(), 0); goToLicensePage.setText(content5); goToLicensePage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { LicenseFragment fragment = LicenseFragment.newInstance(); getFragmentManager().beginTransaction().add(R.id.container, fragment).addToBackStack(null).commit(); } }); devLight.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Uri uri = Uri.parse("http://devLight.com.ua"); getActivity().getApplicationContext().startActivity( Intent.createChooser(new Intent(Intent.ACTION_VIEW, uri), Constants.BROWSER_CHOOSER) .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); } }); viktor.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Uri uri = Uri.parse("http://vk.com/sokeoner"); getActivity().getApplicationContext().startActivity( Intent.createChooser(new Intent(Intent.ACTION_VIEW, uri), Constants.BROWSER_CHOOSER) .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); } }); yura.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Uri uri = Uri.parse("http://vk.com/yura0202"); getActivity().getApplicationContext().startActivity( Intent.createChooser(new Intent(Intent.ACTION_VIEW, uri), Constants.BROWSER_CHOOSER) .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); } }); lyubomir.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Uri uri = Uri.parse("http://vk.com/lubomiru4"); getActivity().getApplicationContext().startActivity( Intent.createChooser(new Intent(Intent.ACTION_VIEW, uri), Constants.BROWSER_CHOOSER) .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); } }); vasil.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Uri uri = Uri.parse("http://vk.com/gigamole"); getActivity().getApplicationContext().startActivity( Intent.createChooser(new Intent(Intent.ACTION_VIEW, uri), Constants.BROWSER_CHOOSER) .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); } }); stantsiya.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Uri uri = Uri.parse("https://vk.com/stantsiya_if"); getActivity().getApplicationContext().startActivity( Intent.createChooser(new Intent(Intent.ACTION_VIEW, uri), Constants.BROWSER_CHOOSER) .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); } }); tf.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Uri uri = Uri.parse("http://typical.if.ua"); getActivity().getApplicationContext().startActivity( Intent.createChooser(new Intent(Intent.ACTION_VIEW, uri), Constants.BROWSER_CHOOSER) .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); } }); our_site_ref.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Uri uri = Uri.parse("http://devLight.com.ua"); getActivity().getApplicationContext().startActivity( Intent.createChooser(new Intent(Intent.ACTION_VIEW, uri), Constants.BROWSER_CHOOSER) .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); } }); return rootView; }
From source file:com.zyz.mobile.book.UserSpan.java
public UserSpan(UserSpanType type, int color, int start, int end, String note, String description) { CharacterStyle object = null;//from w w w . j a v a 2 s . c o m switch (type) { case HIGHLGHT: object = new BackgroundColorSpan(color); break; case UNDERLINE: object = new UnderlineSpan(); case BOOKMARK: case NOTE: break; default: break; } Initialize(object, type, color, start, end, note, description); }
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 a2 s . 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: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//from w ww . ja v a 2 s . c o 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:ca.rmen.android.networkmonitor.app.about.AboutActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.about);/* w w w .j a v a2 s .c o m*/ String versionName; try { PackageInfo packageInfo = getPackageManager().getPackageInfo(getPackageName(), 0); versionName = packageInfo.versionName; } catch (NameNotFoundException e) { // Should never happen throw new AssertionError(e); } ((TextView) findViewById(R.id.txtVersion)).setText(getString(R.string.app_name) + " v" + versionName); TextView tvLibraries = (TextView) findViewById(R.id.about_libraries); SpannableString content = new SpannableString(getString(R.string.about_libraries)); content.setSpan(new UnderlineSpan(), 0, content.length(), 0); tvLibraries.setText(content); getSupportActionBar().setDisplayHomeAsUpEnabled(true); }