0

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());
4

1 に答える 1

0

AlertDialogのメッセージを直接設定する代わりに、TextViewを作成し、HTMLとLinkMovementMethodを設定します。次にAlertDialog.Builder#setView()、このTextViewを使用して呼び出します。コードの使用例:

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");
于 2013-02-01T18:53:41.177 に答える