开发者

Android alert dialog hyper link text [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicate:

Android: Clickable hyperlinks in AlertDialog

Hi, I have created an AlertDialog with two buttons开发者_如何学Go (positive and negative) along with message text. Both the buttons are performing some action already and I want to hyper link the message text in AlertDialog box. Can anyone please help me with how to do this?


You've still got 1 more button (neutral) to play with if you wanted...
Otherwise, I would suggest reading this question.

This is how I have accomplished it though:

AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(R.string.app_name)
                .setIcon(R.drawable.dialog_icon)
               .setMessage(R.string.welcome_text)
               .setCancelable(true)
               .setNegativeButton(R.string.okay, new DialogInterface.OnClickListener() {
                   public void onClick(DialogInterface dialog, int id) {
                        dialog.dismiss();
                   }
               });

        AlertDialog welcomeAlert = builder.create();
        welcomeAlert.show();
        // Make the textview clickable. Must be called after show()
        ((TextView)welcomeAlert.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());

I have used regular <a href=".."></a> formatting in my strings.xml

The only thing I don't like about my current solution is that it makes all of the text clickable and not just the links.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜