在警报对话框消息android的特定文本上设置操作

时间:2014-02-18 20:07:23

标签: android alertdialog spannablestring

我必须设置动作以点击警告对话框文本开始活动我该怎么做才能帮忙。 enter image description here

我的代码在这里

SpannableStringBuilder builder = new SpannableStringBuilder();

String reminderMsg = "Please pay your bill now";
Spannable msg = new SpannableString(reminderMsg);
msg.setSpan(new ForegroundColorSpan(Color.BLACK), 0, reminderMsg.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
builder.append(msg);

String click = " Click here";
Spannable wordtoSpan = new SpannableString(click);
wordtoSpan.setSpan(new ForegroundColorSpan(Color.BLUE), 1, click.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
builder.append(wordtoSpan);

new AlertDialog.Builder(MiActivity.this)
        .setMessage(builder)
        .setPositiveButton("OK", null)
        .show();

0 个答案:

没有答案