List of usage examples for android.widget TextView setMovementMethod
public final void setMovementMethod(MovementMethod movement)
From source file:com.eyekabob.VenueInfo.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.venue_info); findViewById(R.id.findLiveMusicButton).setOnClickListener(linksListener); findViewById(R.id.aboutButton).setOnClickListener(linksListener); findViewById(R.id.contactButton).setOnClickListener(linksListener); Venue thisVenue = (Venue) getIntent().getExtras().get("venue"); Map<String, String> params = new HashMap<String, String>(); params.put("venue", thisVenue.getId()); TextView nameView = (TextView) findViewById(R.id.venueNameView); nameView.setText(thisVenue.getName()); TextView infoView = (TextView) findViewById(R.id.venueInfoView); nameView.setText(thisVenue.getName()); String venueDesc = ""; // TODO: Padding instead of whitespace if (!thisVenue.getCity().equals("") && !thisVenue.getStreet().equals("")) { // TODO: I18N venueDesc += "Address:\n " + thisVenue.getStreet() + "\n " + thisVenue.getCity(); }/*from w w w .j a v a 2 s .c om*/ infoView.setText(venueDesc); TextView websiteView = (TextView) findViewById(R.id.venueMoreInfoView); if (!"".equals((thisVenue.getUrl().toString()))) { // TODO: I18N websiteView.setText(Html.fromHtml("<a href=\"" + thisVenue.getUrl() + "\">More Information</a>")); websiteView.setMovementMethod(LinkMovementMethod.getInstance()); } Uri uri = EyekabobHelper.LastFM.getUri("venue.getEvents", params); new RequestTask().execute(uri.toString()); }
From source file:widget.map.com.urlocationmapwidget.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 . ja v a2 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.dialog_fragment_about, null); aboutBodyView.setText(aboutBody); aboutBodyView.setMovementMethod(new LinkMovementMethod()); return new AlertDialog.Builder(getActivity()).setTitle(R.string.menu_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.itbooks.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 v a2s . 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, 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.doomonafireball.hackerswiperfree.android.activity.MainActivity.java
private void makeLinksFocusable(TextView tv) { MovementMethod m = tv.getMovementMethod(); if ((m == null) || !(m instanceof LinkMovementMethod)) { if (tv.getLinksClickable()) { tv.setMovementMethod(LinkMovementMethod.getInstance()); }//from w ww.j av a2s. co m } }
From source file:com.schautup.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 a va 2 s . com String appName = getString(R.string.application_name); 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, appName, 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.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.playground.notification.app.fragments.AboutDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Get app version PackageManager pm = getActivity().getPackageManager(); String packageName = getActivity().getPackageName(); String versionName;//from ww w .j a v a 2s . co 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) { Utils.openExternalBrowser(getActivity(), "http://" + getString(R.string.support_spielplatz_radar)); } }); dialogV.findViewById(R.id.weather_by_ll).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Utils.openExternalBrowser(getActivity(), "http://" + getString(R.string.support_openweathermap)); } }); 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:sysnetlab.android.sdc.ui.fragments.ExperimentViewSensorDataFragment.java
private void updateSensorDataView(List<AbstractSensor> lstSensors, int sensorNo) { if (lstSensors == null || lstSensors.isEmpty()) { ((TextView) mView.findViewById(R.id.textview_fragment_experiment_view_notes_note_text)) .setText(mView.getResources().getString(R.string.text_experiment_has_no_sensors)); return;//from w w w . ja va 2 s .c o m } AbstractSensor sensor = lstSensors.get(sensorNo); ListView listView = (ListView) mView .findViewById(R.id.listview_fragment_experiment_view_sensor_data_sensor_properties); UserInterfaceUtils.fillSensorProperties(getActivity(), listView, sensor, true); String sensorData = getSensorData(sensor, MAXIMUM_LINES_OF_DATA_TO_READ); TextView textView = (TextView) mView.findViewById(R.id.textview_fragment_experiment_view_notes_note_text); if (sensorData.trim().equals("")) { textView.setText(getResources().getString(R.string.text_sensor_has_not_recorded_any_data)); textView.setMovementMethod(new ScrollingMovementMethod()); } else { textView.setText(sensorData); textView.setMovementMethod(new ScrollingMovementMethod()); } }
From source file:com.tassadar.multirommgr.MainActivity.java
@TargetApi(20) private void showDeprecatedLAlert() { SpannableString msg = new SpannableString(getString(R.string.deprecated_l_text)); Linkify.addLinks(msg, Linkify.ALL);/*w w w . j a va 2s .c o m*/ AlertDialog.Builder b = new AlertDialog.Builder(this); b.setTitle(R.string.deprecated_l_title).setCancelable(false).setMessage(msg) .setNegativeButton(R.string.deprecated_l_btn, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { finish(); } }); AlertDialog d = b.create(); d.show(); TextView msgView = (TextView) d.findViewById(android.R.id.message); msgView.setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:open.currency.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); setToolbarEnabled(true);// w w w .j a va2 s.c o m String desGithub = "Visit the <a href='http://openappsproject.github.io/OpenCurrency/'>project page</a> to get more information about OpenCurrency.<br/><br/> 2015 - 2016 OpenAppsProject"; TextView desTV = (TextView) findViewById(R.id.link_github); desTV.setLinksClickable(true); desTV.setMovementMethod(LinkMovementMethod.getInstance()); desTV.setText(Html.fromHtml(desGithub)); currencyArray = getResources().getStringArray(R.array.currencies); currency1 = (EditText) findViewById(R.id.currency1); currency2 = (EditText) findViewById(R.id.currency2); tilCur1 = (TextInputLayout) findViewById(R.id.tilCur1); tilCur2 = (TextInputLayout) findViewById(R.id.tilCur2); Spinner spinner1 = (Spinner) findViewById(R.id.spinner1); Spinner spinner2 = (Spinner) findViewById(R.id.spinner2); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.currencies, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); lastEdited = 1; currency1.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { lastEdited = 1; } }); currency2.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { lastEdited = 2; } }); spinner1.setAdapter(adapter); spinner1.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { cur1 = position; tilCur1.setHint(currencyArray[position]); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); spinner2.setAdapter(adapter); spinner2.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { cur2 = position; tilCur2.setHint(currencyArray[position]); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); setFabEnabled(true); setFabDrawable(ContextCompat.getDrawable(this, R.drawable.ic_check_white_48dp)); setFabListener(new View.OnClickListener() { Double inputValue = Double.valueOf("0"); @Override public void onClick(View v) { currency1.setEnabled(false); currency2.setEnabled(false); try { if (lastEdited == 1) { inputValue = Double.valueOf(currency1.getText().toString()); } else { inputValue = Double.valueOf(currency2.getText().toString()); } } catch (Exception e) { e.printStackTrace(); } if (inputValue.equals(Double.valueOf("0"))) { Snackbar.make(v, R.string.empty_value, Snackbar.LENGTH_LONG).show(); currency1.setEnabled(true); currency2.setEnabled(true); } else if (cur1 == cur2) { Snackbar.make(v, R.string.sam_cur, Snackbar.LENGTH_LONG).show(); currency1.setEnabled(true); currency2.setEnabled(true); } else { Action<Double> doCalculate = new Action<Double>() { @NonNull @Override public String id() { return "calculate"; } @Nullable @Override protected Double run() throws InterruptedException { if (lastEdited == 1) { return calculate(currencyArray[cur1], currencyArray[cur2], inputValue); } else { return calculate(currencyArray[cur2], currencyArray[cur1], inputValue); } } @Override protected void done(@Nullable Double result) { if (result != null) { if (lastEdited == 1) { currency2.setText(String.valueOf(result)); } else { currency1.setText(String.valueOf(result)); } } currency1.setEnabled(true); currency2.setEnabled(true); } }; doCalculate.execute(); } } }); }
From source file:au.id.tmm.anewreader.view.ItemDetailFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.adapter_view_item_detail, container, false); TextView itemTitle = (TextView) view.findViewById(R.id.item_detail_title); TextView subscriptionTitle = (TextView) view.findViewById(R.id.item_detail_subscription_title); TextView content = (TextView) view.findViewById(R.id.item_detail_content); itemTitle.setText(Html.fromHtml(linkWithText(item.getTitle(), item.getCanonicalLink()))); itemTitle.setMovementMethod(LinkMovementMethod.getInstance()); subscriptionTitle.setText(Html.fromHtml( linkWithText(item.getParentSubscription().getTitle(), item.getParentSubscription().getHtmlUrl()))); subscriptionTitle.setMovementMethod(LinkMovementMethod.getInstance()); UrlImageGetter imageGetter = new UrlImageGetter(content, this.getActivity()); Spanned htmlSpan = Html.fromHtml(item.getSummary(), imageGetter, null); content.setText(htmlSpan);/*from w w w . j a va 2s . co m*/ content.setMovementMethod(LinkMovementMethod.getInstance()); return view; }