我有一个包含超链接的警报对话框,但该超链接不可单击。它显示为超链接
val termsDialog = AlertDialog.Builder(this@MainActivity)
val termsView = layoutInflater.inflate(R.layout.termsdialog, null)
val termsBox: CheckBox = termsView.findViewById(R.id.termsCheckbox)
val termsMsg = Html.fromHtml("By using this application you accept to our Terms and Conditions and Privacy Policy. \nMore information <a href=\"https://mylink.com\">here</a>")
termsDialog.setTitle("Terms and Conditions")
termsDialog.setView(termsView)
termsDialog.setMessage(termsMsg)
termsDialog.setPositiveButton("OK") { _, _ -> }
termsDialog.setCancelable(false)
termsBox.setOnCheckedChangeListener { compoundButton, _ ->
if (compoundButton.isChecked) {
storeDialogStatus(true)
} else {
storeDialogStatus(false)
}
}
// Automatic show terms dialog when dialog status is not checked
if (!this.getDialogStatus()) {
termsDialog.show()
}
1条答案
按热度按时间vkc1a9a21#
在
termsdialog.xml
中为消息创建TextView:然后必须在
TextView
上调用setMovementMethod(LinkMovementMethod.getInstance())
: