List of usage examples for android.widget TextView setMovementMethod
public final void setMovementMethod(MovementMethod movement)
From source file:com.desno365.mods.Tabs.FragmentTab3.java
@Override public View onCreateView(LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragmenttab3, container, false); // xml tab TextView textVersion = (TextView) rootView.findViewById(R.id.latest_version_laser_is); // id TextView version textVersion.setText(MainActivity.modsContainer.laser.getVersion()); // MainActivity variable that holds the latest version TextView textCompatibility = (TextView) rootView.findViewById(R.id.laser_compatibility); // id TextView compatibility textCompatibility.setText(MainActivity.modsContainer.laser.getCompatibility()); // MainActivity variable that holds the versions compatibility final TextView textChangelog = (TextView) rootView.findViewById(R.id.laser_changelog); // id TextView changelog textChangelog.setText(android.text.Html.fromHtml(MainActivity.modsContainer.laser.getChangelog())); // MainActivity variable that holds the latest changelog textChangelog.setMovementMethod(android.text.method.LinkMovementMethod.getInstance()); textChangelog.setMaxLines(SharedConstants.CHANGELOG_TEXT_MAX_LINES); final TextView textShowHide = (TextView) rootView.findViewById(R.id.changelog_show_hide_tab3); // id TextView show/hide changelog textShowHide.setText(getResources().getString(R.string.show_changelog)); textShowHide.setOnClickListener(new View.OnClickListener() { @Override// www. j a va 2 s . c o m public void onClick(View v) { if (!displayingAllChangelog) { // get the TextView height that will be used when hiding the changelog changelogHiddenHeight = textChangelog.getHeight(); DesnoUtils.expandTextView(container, textChangelog); displayingAllChangelog = true; textShowHide.setText(getResources().getString(R.string.hide_changelog)); } else { DesnoUtils.collapseTextView(container, textChangelog, changelogHiddenHeight); displayingAllChangelog = false; textShowHide.setText(getResources().getString(R.string.show_changelog)); } } }); // make the show/hide button invisible if it is not necessary ViewTreeObserver vto = textShowHide.getViewTreeObserver(); vto.addOnGlobalLayoutListener(new android.view.ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { if (textChangelog.getLineCount() <= SharedConstants.CHANGELOG_TEXT_MAX_LINES) { textShowHide.setVisibility(View.GONE); } else { textShowHide.setVisibility(View.VISIBLE); } } }); return rootView; }
From source file:com.desno365.mods.Tabs.FragmentTab2.java
@Override public View onCreateView(LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragmenttab2, container, false); // xml tab TextView textVersion = (TextView) rootView.findViewById(R.id.latest_version_portal_is); // id TextView version textVersion.setText(MainActivity.modsContainer.portal.getVersion()); // MainActivity variable that holds the latest version TextView textCompatibility = (TextView) rootView.findViewById(R.id.portal_compatibility); // id TextView compatibility textCompatibility.setText(MainActivity.modsContainer.portal.getCompatibility()); // MainActivity variable that holds the versions compatibility final TextView textChangelog = (TextView) rootView.findViewById(R.id.portal_changelog); // id TextView changelog textChangelog.setText(android.text.Html.fromHtml(MainActivity.modsContainer.portal.getChangelog())); // MainActivity variable that holds the latest changelog textChangelog.setMovementMethod(android.text.method.LinkMovementMethod.getInstance()); textChangelog.setMaxLines(SharedConstants.CHANGELOG_TEXT_MAX_LINES); final TextView textShowHide = (TextView) rootView.findViewById(R.id.changelog_show_hide_tab2); // id TextView show/hide changelog textShowHide.setText(getResources().getString(R.string.show_changelog)); textShowHide.setOnClickListener(new View.OnClickListener() { @Override//w w w. j a v a 2 s .co m public void onClick(View v) { if (!displayingAllChangelog) { // get the TextView height that will be used when hiding the changelog changelogHiddenHeight = textChangelog.getHeight(); DesnoUtils.expandTextView(container, textChangelog); displayingAllChangelog = true; textShowHide.setText(getResources().getString(R.string.hide_changelog)); } else { DesnoUtils.collapseTextView(container, textChangelog, changelogHiddenHeight); displayingAllChangelog = false; textShowHide.setText(getResources().getString(R.string.show_changelog)); } } }); // make the show/hide button invisible if it is not necessary ViewTreeObserver vto = textShowHide.getViewTreeObserver(); vto.addOnGlobalLayoutListener(new android.view.ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { if (textChangelog.getLineCount() <= SharedConstants.CHANGELOG_TEXT_MAX_LINES) { textShowHide.setVisibility(View.GONE); } else { textShowHide.setVisibility(View.VISIBLE); } } }); return rootView; }
From source file:com.desno365.mods.Tabs.FragmentTab7.java
@Override public View onCreateView(LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragmenttab7, container, false); // xml tab TextView textVersion = (TextView) rootView.findViewById(R.id.latest_version_unreal_is); // id TextView version textVersion.setText(MainActivity.modsContainer.unreal.getVersion()); // MainActivity variable that holds the latest version TextView textCompatibility = (TextView) rootView.findViewById(R.id.unreal_compatibility); // id TextView compatibility textCompatibility.setText(MainActivity.modsContainer.unreal.getCompatibility()); // MainActivity variable that holds the versions compatibility final TextView textChangelog = (TextView) rootView.findViewById(R.id.unreal_changelog); // id TextView changelog textChangelog.setText(android.text.Html.fromHtml(MainActivity.modsContainer.unreal.getChangelog())); // MainActivity variable that holds the latest changelog textChangelog.setMovementMethod(android.text.method.LinkMovementMethod.getInstance()); textChangelog.setMaxLines(SharedConstants.CHANGELOG_TEXT_MAX_LINES); final TextView textShowHide = (TextView) rootView.findViewById(R.id.changelog_show_hide_tab7); // id TextView show/hide changelog textShowHide.setText(getResources().getString(R.string.show_changelog)); textShowHide.setOnClickListener(new View.OnClickListener() { @Override//w w w. j a v a 2s . c om public void onClick(View v) { if (!displayingAllChangelog) { // get the TextView height that will be used when hiding the changelog changelogHiddenHeight = textChangelog.getHeight(); DesnoUtils.expandTextView(container, textChangelog); displayingAllChangelog = true; textShowHide.setText(getResources().getString(R.string.hide_changelog)); } else { DesnoUtils.collapseTextView(container, textChangelog, changelogHiddenHeight); displayingAllChangelog = false; textShowHide.setText(getResources().getString(R.string.show_changelog)); } } }); // make the show/hide button invisible if it is not necessary ViewTreeObserver vto = textShowHide.getViewTreeObserver(); vto.addOnGlobalLayoutListener(new android.view.ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { if (textChangelog.getLineCount() <= SharedConstants.CHANGELOG_TEXT_MAX_LINES) { textShowHide.setVisibility(View.GONE); } else { textShowHide.setVisibility(View.VISIBLE); } } }); return rootView; }
From source file:org.liberty.android.fantastischmemo.downloader.DownloaderFE.java
@Override protected void fetchDatabase(final DownloadItem di) { View alertView = View.inflate(this, R.layout.link_alert, null); TextView textView = (TextView) alertView.findViewById(R.id.link_alert_message); textView.setMovementMethod(LinkMovementMethod.getInstance()); textView.setText(/*from w ww .j av a 2 s. c o m*/ Html.fromHtml(getString(R.string.downloader_download_alert_message) + di.getDescription())); new AlertDialog.Builder(this).setView(alertView) .setTitle(getString(R.string.downloader_download_alert) + di.getTitle()) .setPositiveButton(getString(R.string.yes_text), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { mProgressDialog = ProgressDialog.show(DownloaderFE.this, getString(R.string.loading_please_wait), getString(R.string.loading_downloading)); new Thread() { public void run() { try { downloadDatabase(di); mHandler.post(new Runnable() { public void run() { mProgressDialog.dismiss(); String dbpath = AMEnv.DEFAULT_ROOT_PATH; new AlertDialog.Builder(DownloaderFE.this) .setTitle(R.string.downloader_download_success) .setMessage( getString(R.string.downloader_download_success_message) + dbpath + di.getTitle() + ".db") .setPositiveButton(R.string.ok_text, null).create().show(); } }); } catch (final Exception e) { Log.e(TAG, "Error downloading", e); mHandler.post(new Runnable() { public void run() { mProgressDialog.dismiss(); new AlertDialog.Builder(DownloaderFE.this) .setTitle(R.string.downloader_download_fail) .setMessage(getString(R.string.downloader_download_fail_message) + " " + e.toString()) .setPositiveButton(R.string.ok_text, null).create().show(); } }); } } }.start(); } }).setNegativeButton(getString(R.string.no_text), null).show(); }
From source file:com.desno365.mods.Tabs.FragmentTab6.java
@Override public View onCreateView(LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragmenttab6, container, false); // xml tab TextView textVersion = (TextView) rootView.findViewById(R.id.latest_version_guns_is); // id TextView version textVersion.setText(MainActivity.modsContainer.desnoGuns.getVersion()); // MainActivity variable that holds the latest version TextView textCompatibility = (TextView) rootView.findViewById(R.id.guns_compatibility); // id TextView compatibility textCompatibility.setText(MainActivity.modsContainer.desnoGuns.getCompatibility()); // MainActivity variable that holds the versions compatibility final TextView textChangelog = (TextView) rootView.findViewById(R.id.guns_changelog); // id TextView changelog textChangelog.setText(android.text.Html.fromHtml(MainActivity.modsContainer.desnoGuns.getChangelog())); // MainActivity variable that holds the latest changelog textChangelog.setMovementMethod(android.text.method.LinkMovementMethod.getInstance()); textChangelog.setMaxLines(SharedConstants.CHANGELOG_TEXT_MAX_LINES); final TextView textShowHide = (TextView) rootView.findViewById(R.id.changelog_show_hide_tab6); // id TextView show/hide changelog textShowHide.setText(getResources().getString(R.string.show_changelog)); textShowHide.setOnClickListener(new View.OnClickListener() { @Override//from w ww .j a v a 2 s . c o m public void onClick(View v) { if (!displayingAllChangelog) { // get the TextView height that will be used when hiding the changelog changelogHiddenHeight = textChangelog.getHeight(); DesnoUtils.expandTextView(container, textChangelog); displayingAllChangelog = true; textShowHide.setText(getResources().getString(R.string.hide_changelog)); } else { DesnoUtils.collapseTextView(container, textChangelog, changelogHiddenHeight); displayingAllChangelog = false; textShowHide.setText(getResources().getString(R.string.show_changelog)); } } }); // make the show/hide button invisible if it is not necessary ViewTreeObserver vto = textShowHide.getViewTreeObserver(); vto.addOnGlobalLayoutListener(new android.view.ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { if (textChangelog.getLineCount() <= SharedConstants.CHANGELOG_TEXT_MAX_LINES) { textShowHide.setVisibility(View.GONE); } else { textShowHide.setVisibility(View.VISIBLE); } } }); return rootView; }
From source file:com.desno365.mods.Tabs.FragmentTab4.java
@Override public View onCreateView(LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragmenttab4, container, false); // xml tab TextView textVersion = (TextView) rootView.findViewById(R.id.latest_version_turrets_is); // id TextView version textVersion.setText(MainActivity.modsContainer.turrets.getVersion()); // MainActivity variable that holds the latest version TextView textCompatibility = (TextView) rootView.findViewById(R.id.turrets_compatibility); // id TextView compatibility textCompatibility.setText(MainActivity.modsContainer.turrets.getCompatibility()); // MainActivity variable that holds the versions compatibility final TextView textChangelog = (TextView) rootView.findViewById(R.id.turrets_changelog); // id TextView changelog textChangelog.setText(android.text.Html.fromHtml(MainActivity.modsContainer.turrets.getChangelog())); // MainActivity variable that holds the latest changelog textChangelog.setMovementMethod(android.text.method.LinkMovementMethod.getInstance()); textChangelog.setMaxLines(SharedConstants.CHANGELOG_TEXT_MAX_LINES); final TextView textShowHide = (TextView) rootView.findViewById(R.id.changelog_show_hide_tab4); // id TextView show/hide changelog textShowHide.setText(getResources().getString(R.string.show_changelog)); textShowHide.setOnClickListener(new View.OnClickListener() { @Override/*from w w w. j a va 2s. c o m*/ public void onClick(View v) { if (!displayingAllChangelog) { // get the TextView height that will be used when hiding the changelog changelogHiddenHeight = textChangelog.getHeight(); DesnoUtils.expandTextView(container, textChangelog); displayingAllChangelog = true; textShowHide.setText(getResources().getString(R.string.hide_changelog)); } else { DesnoUtils.collapseTextView(container, textChangelog, changelogHiddenHeight); displayingAllChangelog = false; textShowHide.setText(getResources().getString(R.string.show_changelog)); } } }); // make the show/hide button invisible if it is not necessary ViewTreeObserver vto = textShowHide.getViewTreeObserver(); vto.addOnGlobalLayoutListener(new android.view.ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { if (textChangelog.getLineCount() <= SharedConstants.CHANGELOG_TEXT_MAX_LINES) { textShowHide.setVisibility(View.GONE); } else { textShowHide.setVisibility(View.VISIBLE); } } }); return rootView; }
From source file:com.desno365.mods.Tabs.FragmentTab5.java
@Override public View onCreateView(LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragmenttab5, container, false); // xml tab TextView textVersion = (TextView) rootView.findViewById(R.id.latest_version_jukebox_is); // id TextView version textVersion.setText(MainActivity.modsContainer.jukebox.getVersion()); // MainActivity variable that holds the latest version TextView textCompatibility = (TextView) rootView.findViewById(R.id.jukebox_compatibility); // id TextView compatibility textCompatibility.setText(MainActivity.modsContainer.jukebox.getCompatibility()); // MainActivity variable that holds the versions compatibility final TextView textChangelog = (TextView) rootView.findViewById(R.id.jukebox_changelog); // id TextView changelog textChangelog.setText(android.text.Html.fromHtml(MainActivity.modsContainer.jukebox.getChangelog())); // MainActivity variable that holds the latest changelog textChangelog.setMovementMethod(android.text.method.LinkMovementMethod.getInstance()); textChangelog.setMaxLines(SharedConstants.CHANGELOG_TEXT_MAX_LINES); final TextView textShowHide = (TextView) rootView.findViewById(R.id.changelog_show_hide_tab5); // id TextView show/hide changelog textShowHide.setText(getResources().getString(R.string.show_changelog)); textShowHide.setOnClickListener(new View.OnClickListener() { @Override//from ww w. ja v a2 s . c o m public void onClick(View v) { if (!displayingAllChangelog) { // get the TextView height that will be used when hiding the changelog changelogHiddenHeight = textChangelog.getHeight(); DesnoUtils.expandTextView(container, textChangelog); displayingAllChangelog = true; textShowHide.setText(getResources().getString(R.string.hide_changelog)); } else { DesnoUtils.collapseTextView(container, textChangelog, changelogHiddenHeight); displayingAllChangelog = false; textShowHide.setText(getResources().getString(R.string.show_changelog)); } } }); // make the show/hide button invisible if it is not necessary ViewTreeObserver vto = textShowHide.getViewTreeObserver(); vto.addOnGlobalLayoutListener(new android.view.ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { if (textChangelog.getLineCount() <= SharedConstants.CHANGELOG_TEXT_MAX_LINES) { textShowHide.setVisibility(View.GONE); } else { textShowHide.setVisibility(View.VISIBLE); } } }); return rootView; }
From source file:com.marstemp.app.fragments.AboutDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Get app version PackageManager pm = getActivity().getPackageManager(); String packageName = getActivity().getPackageName(); String versionName;/*from w w w . j av a 2 s .c o m*/ try { PackageInfo info = pm.getPackageInfo(packageName, 0); versionName = info.versionName; } catch (PackageManager.NameNotFoundException e) { versionName = VERSION_UNAVAILABLE; } // About. SpannableStringBuilder aboutBody = new SpannableStringBuilder(); aboutBody.append( Html.fromHtml(getString(R.string.about_body, getString(R.string.application_name), versionName))); // Licenses. 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); aboutBody.append("\n\n"); aboutBody.append(licensesLink); // End User License Agreement. SpannableString eulaLink = new SpannableString(getString(R.string.about_eula)); eulaLink.setSpan(new ClickableSpan() { @Override public void onClick(View view) { showEula(getActivity()); } }, 0, eulaLink.length(), 0); aboutBody.append("\n\n"); aboutBody.append(eulaLink); // Show "About" dialog. LayoutInflater layoutInflater = (LayoutInflater) getActivity() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View dialogV = layoutInflater.inflate(R.layout.fragment_dialog_about, null); ; TextView aboutBodyView = (TextView) dialogV.findViewById(R.id.dialog_text_tv); aboutBodyView.setText(aboutBody); aboutBodyView.setMovementMethod(new LinkMovementMethod()); dialogV.findViewById(R.id.powered_by_ll).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { WebViewActivity.showInstance(getActivity(), getString(R.string.lbl_maas), Prefs.getInstance().getApiHome()); } }); return new AlertDialog.Builder(getActivity()).setTitle(R.string.action_about).setView(dialogV) .setPositiveButton(R.string.btn_ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); } }).create(); }
From source file:com.hpush.app.fragments.AboutDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Get app version PackageManager pm = getActivity().getPackageManager(); String packageName = getActivity().getPackageName(); String versionName;/*from w ww .ja va 2s. com*/ try { PackageInfo info = pm.getPackageInfo(packageName, 0); versionName = info.versionName; } catch (PackageManager.NameNotFoundException e) { versionName = VERSION_UNAVAILABLE; } // About. SpannableStringBuilder aboutBody = new SpannableStringBuilder(); aboutBody.append( Html.fromHtml(getString(R.string.about_body, getString(R.string.application_name), versionName))); // Licenses. 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); aboutBody.append("\n\n"); aboutBody.append(licensesLink); // End User License Agreement. SpannableString eulaLink = new SpannableString(getString(R.string.about_eula)); eulaLink.setSpan(new ClickableSpan() { @Override public void onClick(View view) { showEula(getActivity()); } }, 0, eulaLink.length(), 0); aboutBody.append("\n\n"); aboutBody.append(eulaLink); // Show "About" dialog. LayoutInflater layoutInflater = (LayoutInflater) getActivity() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); TextView aboutBodyView = (TextView) layoutInflater.inflate(R.layout.fragment_dialog_about, null); aboutBodyView.setText(aboutBody); aboutBodyView.setMovementMethod(new LinkMovementMethod()); return new AlertDialog.Builder(getActivity()).setTitle(R.string.lbl_about).setView(aboutBodyView) .setPositiveButton(R.string.btn_ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); } }).create(); }
From source file:com.osc.tweet.app.fragments.AboutDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Get app version PackageManager pm = getActivity().getPackageManager(); String packageName = getActivity().getPackageName(); String versionName;/*from w w w .java 2 s.c om*/ try { PackageInfo info = pm.getPackageInfo(packageName, 0); versionName = info.versionName; } catch (PackageManager.NameNotFoundException e) { versionName = VERSION_UNAVAILABLE; } // About. SpannableStringBuilder aboutBody = new SpannableStringBuilder(); aboutBody.append( Html.fromHtml(getString(R.string.about_body, getString(R.string.application_name), versionName))); // Licenses. 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); aboutBody.append("\n\n"); aboutBody.append(licensesLink); // End User License Agreement. SpannableString eulaLink = new SpannableString(getString(R.string.about_eula)); eulaLink.setSpan(new ClickableSpan() { @Override public void onClick(View view) { showEula(getActivity()); } }, 0, eulaLink.length(), 0); aboutBody.append("\n\n"); aboutBody.append(eulaLink); // Show "About" dialog. LayoutInflater layoutInflater = (LayoutInflater) getActivity() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); TextView aboutBodyView = (TextView) layoutInflater.inflate(R.layout.fragment_dialog_about, null); aboutBodyView.setText(aboutBody); aboutBodyView.setMovementMethod(new LinkMovementMethod()); return new AlertDialog.Builder(getActivity()).setTitle(R.string.action_about).setView(aboutBodyView) .setPositiveButton(R.string.btn_ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); } }).create(); }