我想要单击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());发布于 2013-02-02 02:53:41
不是直接设置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");https://stackoverflow.com/questions/14651835
复制相似问题