Sunday, August 15, 2010

How to add a linkable text in Dialog

It's a example to add a linkable text in a dialog, using Linkify.

linkable text in Dialog

 private void openOptionsMySiteDialog()
{

final SpannableString stMyWeb = new SpannableString("http://android-er.blogspot.com/");
Linkify.addLinks(stMyWeb, Linkify.ALL);

final AlertDialog aboutDialog = new AlertDialog.Builder(MyActivity.this)
.setMessage(stMyWeb)
.setPositiveButton("OK", new DialogInterface.OnClickListener() {

@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
}})
.create();

aboutDialog.show();

((TextView)aboutDialog.findViewById(android.R.id.message))
.setMovementMethod(LinkMovementMethod.getInstance());

}

1 comment: