List of usage examples for android.text.method LinkMovementMethod getInstance
public static MovementMethod getInstance()
From source file:com.dev.campus.event.EventFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_event, container, false); ((TextView) rootView.findViewById(R.id.event_view_title)).setText(mEvent.getTitle()); ((TextView) rootView.findViewById(R.id.event_view_category)).setText(mEvent.getCategory()); ((TextView) rootView.findViewById(R.id.event_view_date)).setText(mEvent.getStringDate()); TextView detailsView = (TextView) rootView.findViewById(R.id.event_view_details); detailsView.setText(Html.fromHtml(mEvent.getDetails())); Linkify.addLinks(detailsView, Linkify.EMAIL_ADDRESSES); detailsView.setMovementMethod(LinkMovementMethod.getInstance()); return rootView; }
From source file:com.facebook.android.UpdateStatusResultDialog.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mHandler = new Handler(); setContentView(R.layout.update_post_response); LayoutParams params = getWindow().getAttributes(); params.width = LayoutParams.FILL_PARENT; params.height = LayoutParams.FILL_PARENT; getWindow().setAttributes((android.view.WindowManager.LayoutParams) params); mOutput = (TextView) findViewById(R.id.apiOutput); mOutput.setText(values.toString());// w ww. ja va2 s . c o m mUsefulTip = (TextView) findViewById(R.id.usefulTip); mUsefulTip.setMovementMethod(LinkMovementMethod.getInstance()); mViewPostButton = (Button) findViewById(R.id.view_post_button); mDeletePostButton = (Button) findViewById(R.id.delete_post_button); final String postId = values.getString("post_id"); mViewPostButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { /* * Source tag: view_post_tag */ Utility.mAsyncRunner.request(postId, new WallPostRequestListener()); } }); mDeletePostButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { /* * Source tag: delete_post_tag */ Utility.mAsyncRunner.request(postId, new Bundle(), "DELETE", new WallPostDeleteListener(), null); } }); }
From source file:com.ketanolab.simidic.adapters.AdaptadorViewPager.java
@Override public Object instantiateItem(View collection, int position) { LinearLayout linearLayout = (LinearLayout) View.inflate(contexto, R.layout.diccionario2, null); // titulo//from w ww. ja v a 2 s. co m TextView textoTitulo = (TextView) linearLayout.findViewById(R.id.textview_titulo); textoTitulo.setText(listaTitulos.get(position)); // Subtitulo TextView textoSubtitulo = (TextView) linearLayout.findViewById(R.id.textview_subtitulo); textoSubtitulo.setText(listaSubtitulos.get(position)); // Extra TextView textoExtra = (TextView) linearLayout.findViewById(R.id.textview_extra); textoExtra.setText(listaExtras.get(position)); textoExtra.setMovementMethod(LinkMovementMethod.getInstance()); // Imagen ImageView imagen = (ImageView) linearLayout.findViewById(R.id.imageview_logo); imagen.setImageResource(listaBitmaps.get(position)); ((ViewPager) collection).addView(linearLayout, 0); return linearLayout; }
From source file:com.robomorphine.fragment.AboutDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { LayoutInflater inflater = LayoutInflater.from(getActivity()); View view = inflater.inflate(R.layout.fragment_about, null); TextView version = (TextView) view.findViewById(R.id.version); TextView author = (TextView) view.findViewById(R.id.author); TextView project = (TextView) view.findViewById(R.id.project); TextView license = (TextView) view.findViewById(R.id.license); TextView repo = (TextView) view.findViewById(R.id.repo); author.setMovementMethod(LinkMovementMethod.getInstance()); project.setMovementMethod(LinkMovementMethod.getInstance()); license.setMovementMethod(LinkMovementMethod.getInstance()); repo.setMovementMethod(LinkMovementMethod.getInstance()); version.setText(getVersion());//from w w w.j a v a 2 s. c o m author.setText(linkify(R.string.author, R.string.author_link)); project.setText(linkify(R.string.project, R.string.project_link)); license.setText(linkify(R.string.license, R.string.license_link)); repo.setText(linkify(R.string.repo, R.string.repo_link)); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.about); builder.setView(view); builder.setCancelable(true); builder.setPositiveButton(android.R.string.ok, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dismiss(); } }); return builder.create(); }
From source file:com.hybris.mobile.activity.ProductDetailActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.product_detail); getActionBar().setHomeButtonEnabled(true); // Allow links in promotions label TextView promotionsTextView = (TextView) findViewById(R.id.textViewPromotion); promotionsTextView.setMovementMethod(LinkMovementMethod.getInstance()); mLinks = new ArrayList<ProductOptionItem>(); mVariantOptions = new ArrayList<String>(); mAdapter = new ProductVariantAdapter(this, mLinks); mListView = (ListView) findViewById(R.id.list_variants); mListView.setAdapter(mAdapter);// w w w .j a v a 2s .co m mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> a, View v, int position, long l) { int selected = -1; mVariantOptions.clear(); for (ProductOptionItem option : mProduct.getAllOptions()) { if (option.isSelectedOption()) { continue; } if (option.getQualifier().equals(mLinks.get(position).getQualifier())) { if (!mVariantOptions.contains(getVariantOption(option))) { mVariantOptions.add(getVariantOption(option)); if (option.getValue().equals(mLinks.get(position).getValue())) { selected = mVariantOptions.size() - 1; } } } } ProductVariantDialogFragment fragment = new ProductVariantDialogFragment( mLinks.get(position).getQualifier(), mLinks.get(position).getName(), selected, mVariantOptions.toArray(new String[0]), new DoneClickListener() { @Override public void onClick(String qualifier, int position) { if (position < 0) return; for (ProductOptionItem option : mProduct.getAllOptions()) { if (option.getQualifier().equals(qualifier)) { if (getVariantOption(option).equals(mVariantOptions.get(position))) { if (!StringUtils.equals(mProduct.getCode(), option.getCode())) { Intent intent = new Intent(ProductDetailActivity.this, ProductDetailActivity.class); intent.putExtra(DataConstants.PRODUCT_CODE, option.getCode()); startActivity(intent); finish(); break; } } } } } }); fragment.show(getFragmentManager(), ""); } }); }
From source file:com.grokkingandroid.sampleapp.samples.data.contentprovider.about.AboutFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { getDialog().setTitle(getResources().getString(R.string.cpsample_about)); View view = inflater.inflate(R.layout.fragment_about, container, false); ViewGroup libParent = (ViewGroup) view.findViewById(R.id.about_container); String[] libTitles = getResources().getStringArray(R.array.cpsample_about_titles); String[] libDescriptions = getResources().getStringArray(R.array.cpsample_about_contents); String libraryPlural = getResources().getQuantityString(R.plurals.cpsample_libraries_plural, libTitles.length);//ww w. j a va2s.c om String aboutText = getResources().getString(R.string.cpsample_about_text, libraryPlural); Spanned spannedAboutText = Html.fromHtml(aboutText); TextView aboutTv = (TextView) libParent.findViewById(R.id.about_text); aboutTv.setText(spannedAboutText); aboutTv.setMovementMethod(LinkMovementMethod.getInstance()); for (int i = 0; i < libTitles.length; i++) { View libContainer = inflater.inflate(R.layout.single_library_layout, libParent, false); TextView currLibTitle = (TextView) libContainer.findViewById(R.id.library_title); currLibTitle.setText(libTitles[i]); TextView currLibDesc = (TextView) libContainer.findViewById(R.id.library_text); Spanned spanned = Html.fromHtml(libDescriptions[i]); currLibDesc.setText(spanned); currLibDesc.setMovementMethod(LinkMovementMethod.getInstance()); libParent.addView(libContainer); } return view; }
From source file:de.elanev.studip.android.app.frontend.AboutFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); getActivity().setTitle(R.string.about_studip_mobile); mVersionTextView.setText(String.format(getString(R.string.version_and_copyright), BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE, Calendar.getInstance().get(Calendar.YEAR))); // Make TextView links clickable mHomepageTextView.setMovementMethod(LinkMovementMethod.getInstance()); mLicensesTextView.setOnClickListener(new View.OnClickListener() { @Override/*from w w w.jav a 2s. c o m*/ public void onClick(View v) { startNewIntent("file:///android_res/raw/license.html", R.string.licenses); } }); mPrivacyTextView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { startNewIntent("file:///android_res/raw/privacy_policy.html", R.string.privacy_policy); } }); mLegalTextView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { startNewIntent("file:///android_res/raw/legal_notice.html", R.string.legal_notice); } }); mFaqTextView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { startNewIntent("file:///android_res/raw/faq.html", R.string.faq); } }); }
From source file:de.grobox.liberario.AboutActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_LEFT_ICON); setContentView(R.layout.activity_about); getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, android.R.drawable.ic_dialog_info); setTitle(getResources().getString(R.string.action_about) + " " + getResources().getString(R.string.app_name)); String versionName;// w ww . j a v a 2 s .com try { versionName = getPackageManager().getPackageInfo(getPackageName(), 0).versionName; } catch (NameNotFoundException e) { versionName = "?.?"; } // add app name and version TextView aboutApp = (TextView) findViewById(R.id.aboutApp); aboutApp.setText(getResources().getString(R.string.app_name) + " " + versionName); // create real paragraphs TextView t = (TextView) findViewById(R.id.aboutTextView); t.setText(Html.fromHtml(getString(R.string.about))); // make links in about text clickable t.setMovementMethod(LinkMovementMethod.getInstance()); }
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. j av a 2s. co m*/ 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(); }
From source file:de.baumann.hhsmoodle.about.About_content.java
static MaterialAboutList createMaterialAboutList(final Context c) { MaterialAboutCard.Builder appCardBuilder = new MaterialAboutCard.Builder(); // Add items to card appCardBuilder.addItem(//from w ww. j a va 2 s . co m 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.school), "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/HHSMoodle/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() { final AlertDialog d = new AlertDialog.Builder(c).setTitle(R.string.about_title) .setMessage(helper_main.textSpannable(c.getString(R.string.about_text))) .setPositiveButton(c.getString(R.string.toast_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(ConvenienceBuilder.createEmailItem(c, ContextCompat.getDrawable(c, R.drawable.bug), c.getString(R.string.action_problem_summary), true, "juergen.baumann@huebsch.karlsruhe.de", "HHS Moodle")); 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()); 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("Encrypted Userprefs") .subText(R.string.about_license_5).icon(R.drawable.github_circle) .setOnClickListener(ConvenienceBuilder.createWebViewDialogOnClickAction(c, "Encrypted Userprefs", "https://github.com/sveinungkb/encrypted-userprefs", 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("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(), convenienceCardBuilder.build()); }