I have string xml formatted as follow:
<string name="dialog_message">My Super beautiful string<a href="https://mylink.com">Click me!</a>.\n\n\n\nVersion %1$s Build %2$s</string>
Then I have an AlertDialog like this:
String message = context.getString(R.string.dialog_message, "My Version Name", "3");
AlertDialog builder =
new AlertDialog.Builder(context, R.style.AlertDialogCustom).setTitle(context.getResources().getString(R.string.app_name))
.setCancelable(false)
.setIcon(R.mipmap.ic_launcher_home)
.setMessage(message)
.create();
builder.show();
((TextView)builder.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());
((TextView)builder.findViewById(android.R.id.message)).setGravity(Gravity.CENTER_VERTICAL);
But it doesn't work (link not clickable)..it only work if I call .setMessage(R.string.dialog_message)
Why it doesn't work? I've tried also with .setView()
method with custom TextView