0

タイトルと画像を含むアラートビルダーがあります。

AlertDialog.Builder builder = new AlertDialog.Builder(activity);                   
builder.setTitle(R.string.pull);
builder.setIcon(R.drawable.tira_cable);
builder.setPositiveButton(R.string.accept, new DialogInterface.OnClickListener() {
   public void onClick(DialogInterface dialog, int id) {
      //actions
   }
   });
AlertDialog dialog = builder.create();
dialog.show();

setIcon 行にコメントするとタイトルが表示されるため、問題がタイトルではなく画像にあることを確認しました。

4

2 に答える 2

1

このスニペットを使用して修正してください!!

new AlertDialog.Builder(getApplicationContext())
                            .setIcon(android.R.drawable.ic_dialog_info)
                            .setTitle(getResources().getString(R.string.pull))
                            .setCancelable(false)
                            .setMessage("Quistion???")
                            .setPositiveButton("Yes",
                                    new DialogInterface.OnClickListener() {
                                        public void onClick(
                                                DialogInterface dialog,
                                                int which) {

                                        }

                                    })
                            .setNegativeButton("No",
                                    new DialogInterface.OnClickListener() {
                                        public void onClick(
                                                DialogInterface dialog,
                                                int which) {

                                        }
                                    }).show();
于 2013-03-20T09:18:35.593 に答える
1

次のように使用する必要があります:

AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.setTitle(getResources().getString(R.string.pull));
            builder.setIcon(R.drawable.ic_action_search);
            builder.setPositiveButton("OK",
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                            // actions
                        }
                    });
            AlertDialog dialog = builder.create();
            dialog.show();

あなたのタイトル ll 現在表示中...

于 2013-03-20T09:23:39.697 に答える