【发布时间】:2016-03-15 22:52:31
【问题描述】:
我想在我的 AlertDialog 中显示一个链接,但多次尝试后它仍然显示为纯文本。
我已尝试以下链接中的建议: How can I get clickable hyperlinks in AlertDialog from a string resource?
这是我目前的状态:
final TextView msg = new TextView(context);
final SpannableString s = new SpannableString("https://play.google.com/store/apps/details?id=com.google.zxing.client.android");
Linkify.addLinks(s, Linkify.WEB_URLS);
msg.setText("BradcodeScanner app must be installed on your phone\n" +
"click on the link below.\n\n" +s);
msg.setMovementMethod(LinkMovementMethod.getInstance());
info_img = (ImageView) findViewById(R.id.qr_info);
info_img.setOnClickListener(new View.OnClickListener() {
public void onClick(View v)
{
new AlertDialog.Builder(context)
.setTitle("QR Location Scan")
.setView(msg)
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
return;
}
})
.setIcon(android.R.drawable.ic_dialog_info)
.show();
}
});
【问题讨论】:
-
你应该试试 ClickableSpan。试试this。
标签: android android-alertdialog