-
-
Save codingwithsara/a24e9db011c440088f618b878b90edbd to your computer and use it in GitHub Desktop.
AlertDialog - HTML
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package jp.codeforfun.test; | |
import android.app.AlertDialog; | |
import android.content.DialogInterface; | |
import android.support.v7.app.AppCompatActivity; | |
import android.os.Bundle; | |
import android.text.Html; | |
import android.text.method.LinkMovementMethod; | |
import android.widget.TextView; | |
public class MainActivity extends AppCompatActivity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
String message = "Google検索は<br><a href=\"http://google.com\">こちら</a>"; | |
AlertDialog alert = new AlertDialog.Builder(this) | |
.setTitle("タイトル") | |
.setMessage(Html.fromHtml(message)) | |
.setPositiveButton("OK", new DialogInterface.OnClickListener() { | |
@Override | |
public void onClick(DialogInterface dialogInterface, int i) { | |
//「OK」が押された時の処理を書く | |
} | |
}) | |
.show(); | |
((TextView) alert.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment