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.
- ¿Cómo mover una Textview dinámicamente en la pantalla? (Framelayout)
- Single TextView con texto coloreado múltiple
- Cómo funciona autolink: map work
- Cómo cambiar el texto de un TextView en el encabezado del cajón de navegación?
- Obtener el texto visible actual en la vista de texto
Digamos por ejemplo:
- Cuando el usuario haga clic en la palabra "Registrar" en la vista de texto anterior, tengo que invocar la nueva intención.
- Cuando el usuario haga clic en la palabra
"Terms"
, tengo que invocar otro nuevo Intent (una actividad con webview como términos tieneURL 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,
- Valor entero en TextView
- ¿Es posible escalar drawableleft & drawableright en textview?
- Vista lateral con XML Android
- No puede desplazar el ViewPager al tocar TextView (con android: gravity = "center") en él
- Android: Crear TextView que parpadea cuando se hace clic
- Grados (como en Grados Celsius / Fahrenheit) en un TextView
- Campo o etiqueta oculto en TextView?
- Custom TextView en android con diferentes palabras de color
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.
- La aplicación se bloquea al agregar un ImageView
- Cordova – Error: Error al recuperar plataforma android