List of usage examples for android.widget TextView setMovementMethod
public final void setMovementMethod(MovementMethod movement)
From source file:com.google.android.apps.muzei.settings.AboutActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.about_activity); getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); ((Toolbar) findViewById(R.id.app_bar)).setNavigationOnClickListener(new View.OnClickListener() { @Override//from ww w. j av a 2 s.co m public void onClick(View view) { onNavigateUp(); } }); if (savedInstanceState == null) { getSupportFragmentManager().beginTransaction() .add(R.id.demo_view_container, MuzeiRendererFragment.createInstance(true, false)).commit(); } // Get app version PackageManager pm = getPackageManager(); String packageName = getPackageName(); String versionName; try { PackageInfo info = pm.getPackageInfo(packageName, 0); versionName = info.versionName; } catch (PackageManager.NameNotFoundException e) { versionName = VERSION_UNAVAILABLE; } // Build the about body view and append the link to see OSS licenses TextView versionView = (TextView) findViewById(R.id.app_version); versionView.setText(Html.fromHtml(getString(R.string.about_version_template, versionName))); TextView aboutBodyView = (TextView) findViewById(R.id.about_body); aboutBodyView.setText(Html.fromHtml(getString(R.string.about_body))); aboutBodyView.setMovementMethod(new LinkMovementMethod()); findViewById(R.id.android_experiment_link).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { CustomTabsIntent cti = new CustomTabsIntent.Builder().setShowTitle(true) .setToolbarColor(ContextCompat.getColor(AboutActivity.this, R.color.theme_primary)).build(); try { cti.launchUrl(AboutActivity.this, Uri.parse("https://www.androidexperiments.com/experiment/muzei")); } catch (ActivityNotFoundException ignored) { } } }); }
From source file:de.atomfrede.android.scc.about.AboutDialogFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.dialog_about, container, false); Resources resources = getActivity().getResources(); getDialog().setTitle(resources.getString(R.string.about_header)); // Look for all text views and fill them with data String app_ver = ""; try {//from w ww. ja va 2s.c o m app_ver = this.getActivity().getPackageManager().getPackageInfo(this.getActivity().getPackageName(), 0).versionName; } catch (NameNotFoundException e) { Log.v(TAG, e.getMessage()); } String appName = resources.getString(R.string.app_name); String homepage = resources.getString(R.string.link_homepage); String androidAnnotations = resources.getString(R.string.link_android_annotations); String viewpagerIndicator = resources.getString(R.string.link_viewpager_indicator); String greendao = resources.getString(R.string.link_viewpager_green_dao); TextView versionText = (TextView) v.findViewById(R.id.version_text); versionText.setText("Version " + app_ver); TextView appNameText = (TextView) v.findViewById(R.id.app_name_text); appNameText.setText(appName); TextView aboutAppNameText = (TextView) v.findViewById(R.id.scc_application_text); aboutAppNameText.setText(resources.getString(R.string.about_app_name)); TextView homepageText = (TextView) v.findViewById(R.id.homepage_link_text); homepageText.setText(Html.fromHtml(homepage)); homepageText.setMovementMethod(LinkMovementMethod.getInstance()); TextView androidAnnotationsText = (TextView) v.findViewById(R.id.android_annotations_text); androidAnnotationsText.setText(Html.fromHtml(androidAnnotations)); androidAnnotationsText.setMovementMethod(LinkMovementMethod.getInstance()); TextView viewpagerText = (TextView) v.findViewById(R.id.viewpager_text); viewpagerText.setText(Html.fromHtml(viewpagerIndicator)); viewpagerText.setMovementMethod(LinkMovementMethod.getInstance()); TextView greendaoText = (TextView) v.findViewById(R.id.greendao_text); greendaoText.setText(Html.fromHtml(greendao)); greendaoText.setMovementMethod(LinkMovementMethod.getInstance()); Button feedbackButton = (Button) v.findViewById(R.id.feedback_button); feedbackButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { sendFeedbackMail(); } }); return v; }
From source file:org.da_cha.android.bluegnss.MainActivity.java
private void displayAboutDialog() { View messageView = getLayoutInflater().inflate(R.layout.about, null, false); // we need this to enable html links TextView textView = (TextView) messageView.findViewById(R.id.about_license); textView.setMovementMethod(LinkMovementMethod.getInstance()); // When linking text, force to always use default color. This works // around a pressed color state bug. int defaultColor = textView.getTextColors().getDefaultColor(); textView.setTextColor(defaultColor); textView = (TextView) messageView.findViewById(R.id.about_sources); textView.setTextColor(defaultColor); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.about_title); builder.setIcon(R.drawable.gplv3_icon); builder.setView(messageView);//from w ww . jav a 2s .com builder.show(); }
From source file:com.example.nestedarchetypeactivityexample.InnerArchetypeViewerActivity.java
/** * Show info dialog.//from ww w . j a v a 2 s . com * * @param content the content */ private void showInfoDialog(String content) { final Dialog dialog = new Dialog(this); dialog.setTitle("Json Adl Structure"); dialog.setContentView(R.layout.custom_dialog); TextView dialogText = (TextView) dialog.findViewById(R.id.dialogText); dialogText.setMovementMethod(new ScrollingMovementMethod()); dialogText.setText(content); Button dialogButton = (Button) dialog.findViewById(R.id.dialogButtonOK); dialogButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); dialog.show(); }
From source file:com.example.linhdq.test.main_menu.LicenseActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_license); initToolbar();// w w w .j a v a2 s . c o m setToolbarMessage(R.string.pref_title_license); getSupportActionBar().setDisplayHomeAsUpEnabled(true); TextView leptonica = (TextView) findViewById(R.id.textView_leptonica); TextView tesseract = (TextView) findViewById(R.id.textView_tesseract); TextView hocr2pdf = (TextView) findViewById(R.id.textView_hocr2pdf); leptonica.setMovementMethod(new LinkMovementMethod()); tesseract.setMovementMethod(new LinkMovementMethod()); hocr2pdf.setMovementMethod(new LinkMovementMethod()); }
From source file:org.catrobat.catroid.ui.dialogs.TermsOfUseDialogFragment.java
@Override public Dialog onCreateDialog(Bundle bundle) { Bundle fragmentDialogArguments = getArguments(); boolean acceptTermsOfUse = false; if (fragmentDialogArguments != null) { acceptTermsOfUse = fragmentDialogArguments.getBoolean(DIALOG_ARGUMENT_TERMS_OF_USE_ACCEPT, false); }/* w w w . j av a 2 s. c o m*/ View view = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_terms_of_use, null); final CheckBox checkBoxTermsOfUseAcceptedPermanently = (CheckBox) view .findViewById(R.id.dialog_terms_of_use_check_box_agree_permanently); TextView termsOfUseUrlTextView = (TextView) view.findViewById(R.id.dialog_terms_of_use_text_view_url); termsOfUseUrlTextView.setMovementMethod(LinkMovementMethod.getInstance()); String termsOfUseUrl = getString(R.string.terms_of_use_link_template, Constants.CATROBAT_TERMS_OF_USE_URL, getString(R.string.dialog_terms_of_use_link_text)); termsOfUseUrlTextView.setText(Html.fromHtml(termsOfUseUrl)); AlertDialog.Builder termsOfUseDialogBuilder = new AlertDialog.Builder(getActivity()).setView(view) .setTitle(R.string.dialog_terms_of_use_title); if (!acceptTermsOfUse) { termsOfUseDialogBuilder.setNeutralButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); } else { termsOfUseDialogBuilder.setNegativeButton(R.string.dialog_terms_of_use_do_not_agree, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { getActivity().finish(); dialog.dismiss(); } }); termsOfUseDialogBuilder.setPositiveButton(R.string.dialog_terms_of_use_agree, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { if (checkBoxTermsOfUseAcceptedPermanently.isChecked()) { SettingsActivity.setTermsOfServiceAgreedPermanently(getActivity(), true); } dialog.dismiss(); DroneInitializer droneInitializer = ((PreStageActivity) getActivity()) .getDroneInitializer(); if (droneInitializer != null) { droneInitializer.initialiseDrone(); } } }); termsOfUseDialogBuilder.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { Log.d(TAG, "prevent canceling the dialog with back button"); return true; } }); checkBoxTermsOfUseAcceptedPermanently.setVisibility(CheckBox.VISIBLE); checkBoxTermsOfUseAcceptedPermanently.setText(R.string.dialog_terms_of_use_agree_permanent); termsOfUseDialogBuilder.setCancelable(false); } AlertDialog termsOfUseDialog = termsOfUseDialogBuilder.create(); if (!acceptTermsOfUse) { termsOfUseDialog.setCanceledOnTouchOutside(true); } else { termsOfUseDialog.setCancelable(false); termsOfUseDialog.setCanceledOnTouchOutside(false); } return termsOfUseDialog; }
From source file:com.inmobi.ultrapush.InfoRecActivity.java
@Override protected void onResume() { super.onResume(); TextView tv = (TextView) findViewById(R.id.textview_info_rec); tv.setMovementMethod(new ScrollingMovementMethod()); tv.setText("Testing..."); // TODO: No use... tv.invalidate();/*w w w .j a va2 s . c o m*/ // Show supported sample rate and corresponding minimum buffer size. String[] requested = new String[] { "8000", "11025", "16000", "22050", "32000", "44100", "48000", "96000" }; String st = "sampleRate minBufSize\n"; ArrayList<String> validated = new ArrayList<String>(); for (String s : requested) { int rate = Integer.parseInt(s); int minBufSize = AudioRecord.getMinBufferSize(rate, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT); if (minBufSize != AudioRecord.ERROR_BAD_VALUE) { validated.add(s); st += s + " \t" + Integer.toString(minBufSize) + "\n"; } } requested = validated.toArray(new String[0]); tv.setText(st); tv.invalidate(); // Test audio source String[] audioSourceString = new String[] { "DEFAULT", "MIC", "VOICE_UPLINK", "VOICE_DOWNLINK", "VOICE_CALL", "CAMCORDER", "VOICE_RECOGNITION" }; int[] audioSourceId = new int[] { MediaRecorder.AudioSource.DEFAULT, // Default audio source MediaRecorder.AudioSource.MIC, // Microphone audio source MediaRecorder.AudioSource.VOICE_UPLINK, // Voice call uplink (Tx) audio source MediaRecorder.AudioSource.VOICE_DOWNLINK, // Voice call downlink (Rx) audio source MediaRecorder.AudioSource.VOICE_CALL, // Voice call uplink + downlink audio source MediaRecorder.AudioSource.CAMCORDER, // Microphone audio source with same orientation as camera if available, the main device microphone otherwise (apilv7) MediaRecorder.AudioSource.VOICE_RECOGNITION, // Microphone audio source tuned for voice recognition if available, behaves like DEFAULT otherwise. (apilv7) // MediaRecorder.AudioSource.VOICE_COMMUNICATION, // Microphone audio source tuned for voice communications such as VoIP. It will for instance take advantage of echo cancellation or automatic gain control if available. It otherwise behaves like DEFAULT if no voice processing is applied. (apilv11) // MediaRecorder.AudioSource.REMOTE_SUBMIX, // Audio source for a submix of audio streams to be presented remotely. (apilv19) }; tv.append("\n-- Audio Source Test --"); for (String s : requested) { int sampleRate = Integer.parseInt(s); int recBufferSize = AudioRecord.getMinBufferSize(sampleRate, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT); tv.append("\n(" + Integer.toString(sampleRate) + "Hz, MONO, 16BIT)\n"); for (int iass = 0; iass < audioSourceId.length; iass++) { st = ""; // wait for AudioRecord fully released... try { Thread.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } AudioRecord record; record = new AudioRecord(audioSourceId[iass], sampleRate, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT, recBufferSize); if (record.getState() == AudioRecord.STATE_INITIALIZED) { st += audioSourceString[iass] + " successed"; int as = record.getAudioSource(); if (as != audioSourceId[iass]) { int i = 0; while (i < audioSourceId.length) { if (as == audioSourceId[iass]) { break; } i++; } if (i >= audioSourceId.length) { st += "(auto set to \"unknown source\")"; } else { st += "(auto set to " + audioSourceString[i] + ")"; } } st += "\n"; } else { st += audioSourceString[iass] + " failed\n"; } record.release(); record = null; tv.append(st); tv.invalidate(); } } }
From source file:com.xyproto.archfriend.ArchFriendActivity.java
@Override public void onStart() { super.onStart(); // Wait 0.9 sec then close splash screen (replace view context) // TODO: Start loading the list of names Handler handler = new Handler(); handler.postDelayed(new Runnable() { public void run() { setContentView(R.layout.archoverview); }/*from ww w . j a v a 2 s .c o m*/ }, 900); // TODO: Find the best way to load the data for the spinner in the // background. It's currently broken. try { populateSpinner(); populateNews(); } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } catch (ParseException e) { e.printStackTrace(); } TextView tv = (TextView) findViewById(R.id.txtArchNews); tv.setMovementMethod(new ScrollingMovementMethod()); }
From source file:com.italikdesign.pont.chaban.AproposFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { rootView = inflater.inflate(R.layout.fragment_apropos, container, false); // Inflate the layout for this fragment TextView feedback = (TextView) rootView.findViewById(R.id.contact); feedback.setText(Html//from w ww .ja v a 2s. co m .fromHtml("<a href=\"mailto:italikdesignbordeaux@gmail.com\">italikdesignbordeaux@gmail.com</a>")); feedback.setMovementMethod(LinkMovementMethod.getInstance()); TextView feedback1 = (TextView) rootView.findViewById(R.id.lien_site1); feedback1.setText(Html.fromHtml( "<a href=\"http://sedeplacer.bordeaux-metropole.fr/Toutes-les-infos-circulation/Pont-Chaban-Delmas-Fermetures\">http://sedeplacer.bordeaux-metropole.fr</a>")); feedback1.setMovementMethod(LinkMovementMethod.getInstance()); TextView feedback2 = (TextView) rootView.findViewById(R.id.lien_opendata); feedback2.setText(Html.fromHtml( "<a href=\"http://data.bordeaux-metropole.fr/data.php?layer=PREVISIONS_PONT_CHABAN\">http://data.bordeaux-metropole.fr</a>")); feedback2.setMovementMethod(LinkMovementMethod.getInstance()); TextView feedback3 = (TextView) rootView.findViewById(R.id.lien_blog); feedback3.setText( Html.fromHtml("<a href=\"http://www.bordeauxpaquebots.com\">http://www.bordeauxpaquebots.com</a>")); feedback3.setMovementMethod(LinkMovementMethod.getInstance()); TextView feedback4 = (TextView) rootView.findViewById(R.id.lien_twitter); feedback4.setText(Html.fromHtml("<a href=\"https://twitter.com/SebD333\">https://twitter.com/SebD333</a>")); feedback4.setMovementMethod(LinkMovementMethod.getInstance()); TextView feedback5 = (TextView) rootView.findViewById(R.id.licence_name); feedback5.setText(Html.fromHtml( "<a href=\"https://github.com/marlenech/PontChabanDelmas/blob/master/licence\">Apache License Version 2.0</a>")); feedback5.setMovementMethod(LinkMovementMethod.getInstance()); return rootView; }
From source file:com.kawakawaplanning.rssreader.Main.MainActivity.java
private void setSpannableString(View view) { String message = "????????????"; // ?? URL ?// w w w. jav a2 s . c o m Map<String, String> map = new HashMap<String, String>(); map.put("", ""); // SpannableString ?? SpannableString ss = createSpannableString(message, map); // SpannableString ??? TextView textView = (TextView) view.findViewById(R.id.textView19); textView.setText(ss); textView.setMovementMethod(LinkMovementMethod.getInstance()); }