我想点击AlertDialog显示的部分文本并开始一项新活动。 我只是不知道是否有可能。 这是我的代码示例
case R.id.about:
final AlertDialog d = new AlertDialog.Builder(this)
.setPositiveButton(android.R.string.ok, null)
.setMessage(Html.fromHtml(getResources().getString(R.string.infoAuthor)+" <br> <a href=\"https://www.youtube.com">click here for help</a>"))
.create();
d.show();
// Make the textview clickable. Must be called after show()
((TextView)d.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());
答案 0 :(得分:0)
不是直接设置AlertDialog的消息,而是创建TextView并在其上设置HTML和LinkMovementMethod。然后使用此TextView调用AlertDialog.Builder#setView()
。使用代码的示例:
case R.id.about:
TextView tv = new TextView(this);
tv.setText(Html.fromHtml(getResources().getString(R.string.infoAuthor)+" <br> <a href=\"https://www.youtube.com">click here for help</a>");
tv.setMovementMethod(LinkMovementMethod.getInstance());
final AlertDialog d = new AlertDialog.Builder(this)
.setPositiveButton(android.R.string.ok, null)
.setView(tv);
.create();
d.show(getFragmentManager, "tag");