List of usage examples for android.text SpannableString SpannableString
public SpannableString(CharSequence source)
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./* w ww . j a va 2 s . c om*/ * * @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:com.gp.gifshot.plugs.tab.adapter.TabsFragmentAdapter.java
@Override public SpannableString getTabTitle(int position) { CharSequence title = this.getPageTitle(position); if (TextUtils.isEmpty(title)) return new SpannableString(""); SpannableString spannableString = new SpannableString(title); return spannableString; }
From source file:com.myapps.upesse.upes_spefest.events.TabsFragmentAdapter.java
@Override public SpannableString getTabTitle(int position) { CharSequence title = this.getPageTitle(position); if (TextUtils.isEmpty(title)) return new SpannableString(""); return new SpannableString(title); }
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;/*from w ww.j a va 2 s . co m*/ 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:io.github.hidroh.materialistic.widget.preference.HelpListView.java
@Override protected void onFinishInflate() { super.onFinishInflate(); ((TextView) findViewById(R.id.item_new).findViewById(R.id.rank)).append(makeAsteriskSpan()); SpannableString spannable = new SpannableString("+5"); spannable.setSpan(new SuperscriptSpan(), 0, spannable.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE); spannable.setSpan(new RelativeSizeSpan(0.6f), 0, spannable.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE); spannable.setSpan(new ForegroundColorSpan(ContextCompat.getColor(getContext(), R.color.greenA700)), 0, spannable.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE); ((TextView) findViewById(R.id.item_promoted).findViewById(R.id.rank)).append(spannable); TextView comments = (TextView) findViewById(R.id.item_new_comments).findViewById(R.id.comment); SpannableStringBuilder sb = new SpannableStringBuilder("46"); sb.append(makeAsteriskSpan());/*www . j a v a 2s .c o m*/ comments.setText(sb); }
From source file:de.baumann.quitsmoking.about.About_content.java
static MaterialAboutList createMaterialAboutList(final Context c) { MaterialAboutCard.Builder appCardBuilder = new MaterialAboutCard.Builder(); // Add items to card appCardBuilder.addItem(/*w w w. j a va 2 s . c om*/ new MaterialAboutTitleItem.Builder().text(R.string.app_name).icon(R.mipmap.ic_launcher).build()); try { appCardBuilder.addItem(ConvenienceBuilder.createVersionActionItem(c, ContextCompat.getDrawable(c, R.drawable.earth2), "Version", false)); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } appCardBuilder .addItem(new MaterialAboutActionItem.Builder().text(R.string.about_changelog) .subText(R.string.about_changelog_summary).icon(R.drawable.format_list_bulleted) .setOnClickListener(ConvenienceBuilder.createWebsiteOnClickAction(c, Uri.parse("https://github.com/scoute-dich/QuitSmoking/blob/master/CHANGELOG.md"))) .build()); appCardBuilder.addItem(new MaterialAboutActionItem.Builder().text(R.string.about_license) .subText(R.string.about_license_summary).icon(R.drawable.copyright) .setOnClickListener(new MaterialAboutActionItem.OnClickListener() { @Override public void onClick() { SpannableString s; if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) { s = new SpannableString( Html.fromHtml(c.getString(R.string.about_text), Html.FROM_HTML_MODE_LEGACY)); } else { //noinspection deprecation s = new SpannableString(Html.fromHtml(c.getString(R.string.about_text))); } Linkify.addLinks(s, Linkify.WEB_URLS); final AlertDialog d = new AlertDialog.Builder(c).setTitle(R.string.about_title) .setMessage(s).setPositiveButton(c.getString(R.string.yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }) .show(); d.show(); ((TextView) d.findViewById(android.R.id.message)) .setMovementMethod(LinkMovementMethod.getInstance()); } }).build()); appCardBuilder.addItem(new MaterialAboutActionItem.Builder().text(R.string.about_intro) .subText(R.string.about_intro_summary).icon(R.drawable.information_outline_dark) .setOnClickListener(new MaterialAboutActionItem.OnClickListener() { @Override public void onClick() { Intent intent = new Intent(c, Activity_intro.class); intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); c.startActivity(intent); } }).build()); MaterialAboutCard.Builder authorCardBuilder = new MaterialAboutCard.Builder(); authorCardBuilder.title(R.string.about_title_dev); authorCardBuilder.addItem( new MaterialAboutActionItem.Builder().text(R.string.about_dev).subText(R.string.about_dev_summary) .icon(R.drawable.gaukler_faun).setOnClickListener(ConvenienceBuilder .createWebsiteOnClickAction(c, Uri.parse("https://github.com/scoute-dich/"))) .build()); authorCardBuilder.addItem(new MaterialAboutActionItem.Builder().text(R.string.about_donate) .subText(R.string.about_donate_summary).icon(R.drawable.coin) .setOnClickListener(ConvenienceBuilder.createWebsiteOnClickAction(c, Uri.parse( "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=NP6TGYDYP9SHY"))) .build()); MaterialAboutCard.Builder authorCardBuilder2 = new MaterialAboutCard.Builder(); authorCardBuilder2.title(R.string.about_title_ext); authorCardBuilder2.addItem(new MaterialAboutActionItem.Builder().text("Neofaum") .subText(R.string.about_title_ext3).icon(R.drawable.github_circle) .setOnClickListener( ConvenienceBuilder.createWebsiteOnClickAction(c, Uri.parse("https://github.com/naofum"))) .build()); authorCardBuilder2.addItem(new MaterialAboutActionItem.Builder().text("Primokorn") .subText(R.string.about_title_ext4).icon(R.drawable.github_circle) .setOnClickListener( ConvenienceBuilder.createWebsiteOnClickAction(c, Uri.parse("https://github.com/Primokorn"))) .build()); MaterialAboutCard.Builder convenienceCardBuilder = new MaterialAboutCard.Builder(); convenienceCardBuilder.title(R.string.about_title_libs); convenienceCardBuilder .addItem(new MaterialAboutActionItem.Builder().text("Android Onboarder") .subText(R.string.about_license_3).icon(R.drawable.github_circle) .setOnClickListener(ConvenienceBuilder.createWebViewDialogOnClickAction(c, "Android Onboarder", "https://github.com/chyrta/AndroidOnboarder", true, false)) .build()); convenienceCardBuilder.addItem(new MaterialAboutActionItem.Builder().text("Glide") .subText(R.string.about_license_9).icon(R.drawable.github_circle) .setOnClickListener(ConvenienceBuilder.createWebViewDialogOnClickAction(c, "Glide", "https://github.com/bumptech/glide", true, false)) .build()); convenienceCardBuilder .addItem( new MaterialAboutActionItem.Builder().text("Image Picker").subText(R.string.about_license_1) .icon(R.drawable.github_circle) .setOnClickListener(ConvenienceBuilder.createWebViewDialogOnClickAction(c, "Image Picker", "https://github.com/Mariovc/ImagePicker", true, false)) .build()); convenienceCardBuilder.addItem(new MaterialAboutActionItem.Builder().text("Material About Library") .subText(R.string.about_license_7).icon(R.drawable.github_circle) .setOnClickListener(ConvenienceBuilder.createWebViewDialogOnClickAction(c, "Material About Library", "https://github.com/daniel-stoneuk/material-about-library", true, false)) .build()); convenienceCardBuilder.addItem(new MaterialAboutActionItem.Builder().text("Material Date Time Picker") .subText(R.string.about_license_2).icon(R.drawable.github_circle) .setOnClickListener( ConvenienceBuilder.createWebViewDialogOnClickAction(c, "Material Date Time Picker", "https://github.com/wdullaer/MaterialDateTimePicker", true, false)) .build()); convenienceCardBuilder.addItem(new MaterialAboutActionItem.Builder().text("Material Design Icons") .subText(R.string.about_license_8).icon(R.drawable.github_circle) .setOnClickListener(ConvenienceBuilder.createWebViewDialogOnClickAction(c, "Material Design Icons", "https://github.com/Templarian/MaterialDesign", true, false)) .build()); return new MaterialAboutList(appCardBuilder.build(), authorCardBuilder.build(), authorCardBuilder2.build(), convenienceCardBuilder.build()); }
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);/*from w w w . j a va 2 s . c o m*/ 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:de.baumann.sieben.about.About_content.java
static MaterialAboutList createMaterialAboutList(final Context c) { MaterialAboutCard.Builder appCardBuilder = new MaterialAboutCard.Builder(); // Add items to card appCardBuilder.addItem(//from www . j ava2 s . c om new MaterialAboutTitleItem.Builder().text(R.string.app_name).icon(R.mipmap.ic_launcher).build()); try { appCardBuilder.addItem(ConvenienceBuilder.createVersionActionItem(c, ContextCompat.getDrawable(c, R.drawable.earth2), "Version", false)); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } appCardBuilder.addItem(new MaterialAboutActionItem.Builder().text(R.string.about_changelog) .subText(R.string.about_changelog_summary).icon(R.drawable.format_list_bulleted) .setOnClickListener(ConvenienceBuilder.createWebViewDialogOnClickAction(c, c.getString(R.string.about_changelog), "https://github.com/scoute-dich/Sieben/blob/master/CHANGELOG.md", true, false)) .build()); appCardBuilder.addItem(new MaterialAboutActionItem.Builder().text(R.string.about_license) .subText(R.string.about_license_summary).icon(R.drawable.copyright) .setOnClickListener(new MaterialAboutActionItem.OnClickListener() { @Override public void onClick() { SpannableString s; if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) { s = new SpannableString( Html.fromHtml(c.getString(R.string.about_text), Html.FROM_HTML_MODE_LEGACY)); } else { //noinspection deprecation s = new SpannableString(Html.fromHtml(c.getString(R.string.about_text))); } Linkify.addLinks(s, Linkify.WEB_URLS); final AlertDialog d = new AlertDialog.Builder(c).setTitle(R.string.about_title) .setMessage(s).setPositiveButton(c.getString(R.string.app_ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }) .show(); d.show(); ((TextView) d.findViewById(android.R.id.message)) .setMovementMethod(LinkMovementMethod.getInstance()); } }).build()); appCardBuilder.addItem(new MaterialAboutActionItem.Builder().text(R.string.about_intro) .subText(R.string.about_intro_summary).icon(R.drawable.information_outline) .setOnClickListener(new MaterialAboutActionItem.OnClickListener() { @Override public void onClick() { Intent intent = new Intent(c, Activity_intro.class); intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); c.startActivity(intent); } }).build()); MaterialAboutCard.Builder authorCardBuilder = new MaterialAboutCard.Builder(); authorCardBuilder.title(R.string.about_title_dev); authorCardBuilder .addItem(new MaterialAboutActionItem.Builder().text(R.string.about_dev) .subText(R.string.about_dev_summary).icon(R.drawable.gaukler_faun) .setOnClickListener(ConvenienceBuilder.createWebViewDialogOnClickAction(c, c.getString(R.string.about_dev), "https://github.com/scoute-dich/", true, false)) .build()); authorCardBuilder.addItem(new MaterialAboutActionItem.Builder().text(R.string.about_donate) .subText(R.string.about_donate_summary).icon(R.drawable.coin) .setOnClickListener(ConvenienceBuilder.createWebsiteOnClickAction(c, Uri.parse( "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=NP6TGYDYP9SHY"))) .build()); MaterialAboutCard.Builder authorCardBuilder2 = new MaterialAboutCard.Builder(); authorCardBuilder2.title(R.string.about_title_ext); authorCardBuilder2.addItem(new MaterialAboutActionItem.Builder().text("Gilles Coulais") .subText(R.string.about_title_ext1).icon(R.drawable.github_circle) .setOnClickListener( ConvenienceBuilder.createWebsiteOnClickAction(c, Uri.parse("https://github.com/Djiko"))) .build()); authorCardBuilder2.addItem(new MaterialAboutActionItem.Builder().text("jeberger") .subText(R.string.about_title_ext1).icon(R.drawable.github_circle) .setOnClickListener( ConvenienceBuilder.createWebsiteOnClickAction(c, Uri.parse("https://github.com/jeberger"))) .build()); authorCardBuilder2.addItem( new MaterialAboutActionItem.Builder().text("Maurits Cornelis").subText(R.string.about_title_ext4) .icon(R.drawable.github_circle).setOnClickListener(ConvenienceBuilder .createWebsiteOnClickAction(c, Uri.parse("https://github.com/MauritsCornelis"))) .build()); authorCardBuilder2.addItem(new MaterialAboutActionItem.Builder().text("Mathias Lux") .subText(R.string.about_title_ext2).icon(R.drawable.github_circle) .setOnClickListener( ConvenienceBuilder.createWebsiteOnClickAction(c, Uri.parse("https://github.com/dermotte"))) .build()); authorCardBuilder2.addItem(new MaterialAboutActionItem.Builder().text("Neofaum") .subText(R.string.about_title_ext3).icon(R.drawable.github_circle) .setOnClickListener( ConvenienceBuilder.createWebsiteOnClickAction(c, Uri.parse("https://github.com/naofum"))) .build()); MaterialAboutCard.Builder convenienceCardBuilder = new MaterialAboutCard.Builder(); convenienceCardBuilder.title(R.string.about_title_libs); convenienceCardBuilder.addItem(new MaterialAboutActionItem.Builder().text(R.string.about_license_1_title) .subText(R.string.about_license_1).icon(R.drawable.earth2) .setOnClickListener(ConvenienceBuilder.createWebViewDialogOnClickAction(c, "Workout images", "http://almostfearless.com/the-21-minute-workout-or-7-minutes-if-youre-really-fit", true, false)) .build()); convenienceCardBuilder .addItem(new MaterialAboutActionItem.Builder().text(R.string.about_license_2_title) .subText(R.string.about_license_2).icon(R.drawable.earth2) .setOnClickListener(ConvenienceBuilder.createWebViewDialogOnClickAction(c, "Whistle", "http://freesound.org/people/MentalSanityOff/sounds/218318/", true, false)) .build()); convenienceCardBuilder .addItem(new MaterialAboutActionItem.Builder().text("Android Onboarder") .subText(R.string.about_license_3).icon(R.drawable.github_circle) .setOnClickListener(ConvenienceBuilder.createWebViewDialogOnClickAction(c, "Android Onboarder", "https://github.com/chyrta/AndroidOnboarder", true, false)) .build()); convenienceCardBuilder.addItem(new MaterialAboutActionItem.Builder().text("Material About Library") .subText(R.string.about_license_7).icon(R.drawable.github_circle) .setOnClickListener(ConvenienceBuilder.createWebViewDialogOnClickAction(c, "Material About Library", "https://github.com/daniel-stoneuk/material-about-library", true, false)) .build()); convenienceCardBuilder.addItem(new MaterialAboutActionItem.Builder().text("Material Design Icons") .subText(R.string.about_license_8).icon(R.drawable.github_circle) .setOnClickListener(ConvenienceBuilder.createWebViewDialogOnClickAction(c, "Material Design Icons", "https://github.com/Templarian/MaterialDesign", true, false)) .build()); return new MaterialAboutList(appCardBuilder.build(), authorCardBuilder.build(), authorCardBuilder2.build(), convenienceCardBuilder.build()); }
From source file:cn.newgxu.android.notty.ui.AboutBoxDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { View v = getActivity().getLayoutInflater().inflate(R.layout.about, null); TextView tv = (TextView) v.findViewById(android.R.id.text1); SpannableString aboutTxt = new SpannableString(getString(R.string.version) + ": " + AppUtils.version(getActivity()) + "\n" + getString(R.string.about_text)); tv.setText(aboutTxt);//w w w . j a v a 2s . co m Linkify.addLinks(tv, Linkify.ALL); return new AlertDialog.Builder(getActivity()).setTitle(getString(R.string.about)).setCancelable(true) .setIcon(R.drawable.ic_launcher).setPositiveButton(R.string.ok, null).setView(v).create(); }
From source file:com.moubry.worthwatching.ui.BaseActivity.java
public static AlertDialog createWhatsNewAlert(Context context) { final TextView message = new TextView(context); final SpannableString s = new SpannableString(context.getText(R.string.whats_new_message)); Linkify.addLinks(s, Linkify.WEB_URLS); message.setPadding(10, 10, 10, 10);//w w w. ja va 2 s . c om message.setText(s); message.setLinkTextColor(context.getResources().getColor(R.color.blue)); message.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20); message.setMovementMethod(LinkMovementMethod.getInstance()); return new AlertDialog.Builder(context).setTitle(R.string.title_whats_new).setCancelable(true) .setPositiveButton("OK", null).setView(message).create(); }