Cómo configurar mulitple clic evento para la única textview?

Tengo una vista de texto como la siguiente:

txtByRegistering.setText("By Registering you agree to terms and condition and privacy policy"); 

Es sólo un texto grande. Por lo tanto, he utilizado marquesina para desplazar el texto horizontalmente. Que funciona bien. Mi pregunta es, Cómo invocar el evento de clic al hacer clic en el texto de desplazamiento seleccionado.

Digamos por ejemplo:

  1. Cuando el usuario haga clic en la palabra "Registrar" en la vista de texto anterior, tengo que invocar la nueva intención.
  2. Cuando el usuario haga clic en la palabra "Terms" , tengo que invocar otro nuevo Intent (una actividad con webview como términos tiene URL Link ).

Como la palabra "Registro" y "Términos" son URL de la Web, he intentado algo como a continuación:

  String mRegDesc = "By registering you agree to the " + "<a href=\"" + Constant.URL + "/terms_and_conditions" + "\">Terms of Use</a> " + "and " + "<a href=\"" + Constant.URL + "/privacy" + "\">Privacy Policy</a> "; txtByRegistering.setText(Html.fromHtml(mRegDesc)); txtByRegistering.setMovementMethod(LinkMovementMethod.getInstance()); txtByRegistering.setSelected(true); txtByRegistering.setTypeface(mTyFaceOverLockReg, Typeface.BOLD); 

El código anterior funciona bien y me lleva al navegador cuando hago clic en la palabra "Términos" pero deseo ir a la nueva actividad.

Espero que ustedes me pueden ayudar! Gracias,

Finalmente,

Encontré la solución para eso,

Aquí está la solución:

  SpannableString SpanString = new SpannableString( "By Registering you agree to the Terms of Use and Privacy Policy"); ClickableSpan teremsAndCondition = new ClickableSpan() { @Override public void onClick(View textView) { Utils.displayToast("Clickable span terms and codition", SignUp.this); Intent mIntent = new Intent(SignUp.this, CommonWebView.class); mIntent.putExtra("isTermsAndCondition", true); startActivity(mIntent); } }; ClickableSpan privacy = new ClickableSpan() { @Override public void onClick(View textView) { Utils.displayToast("Clickable span terms and codition", SignUp.this); Intent mIntent = new Intent(SignUp.this, CommonWebView.class); mIntent.putExtra("isPrivacyPolicy", true); startActivity(mIntent); } }; SpanString.setSpan(teremsAndCondition, 32, 45, 0); SpanString.setSpan(privacy, 49, 63, 0); SpanString.setSpan(new ForegroundColorSpan(Color.BLUE), 32, 45, 0); SpanString.setSpan(new ForegroundColorSpan(Color.BLUE), 49, 63, 0); SpanString.setSpan(new UnderlineSpan(), 32, 45, 0); SpanString.setSpan(new UnderlineSpan(), 49, 63, 0); txtByRegistering.setMovementMethod(LinkMovementMethod.getInstance()); txtByRegistering.setText(SpanString, BufferType.SPANNABLE); txtByRegistering.setSelected(true); 

Gracias a Shayan pourvatan.

  • Clickable TextView en Android
  • Calcular el tamaño del texto según el ancho del área de texto
  • Selector de texto no funciona
  • En un Android TextView, ¿es posible insertar párrafos?
  • Cómo utilizar TextAppearanceSpan
  • Obtener texto seleccionado de TextView
  • Android textview settext mostrar nullpointer excepción
  • Android: ¿define TextView TextStyle mediante programación?
  • ¿Cómo obtengo el color de fondo de un TextView?
  • Pellizcar Zoom en el texto de vista Android
  • Configuración de un ancho de TextView en java
  • FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.