0

我想用两个按钮显示警报:“Reprendre”和“Plus Tard”。我有以下代码:

alertsyncincomplete = new AlertDialog.Builder(this);
alertsyncincomplete.setCustomTitle(titleAlertSyncIncomplete);
alertsyncincomplete.setPositiveButton("Reprendre", new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog, int which) {

    }
});

alertsyncincomplete.setNegativeButton("Plus tard", new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog, int which) {

    }
});

但我只能看到屏幕上的一个按钮——第一个带有文本“Reprendre”的按钮。我使用AlertDialogsetButtonandsetButton2方法,得到了相同的结果。我将文本“Plus Tard”更改为“OK”(长度更短),然后显示两个按钮。我认为问题应该出在文本的长度上(即使我的按钮上的文本不是很长)。

我该如何解决?

4

2 回答 2

2

这对我有用:

AlertDialog.Builder builder = new AlertDialog.Builder(YouActivity.this);
builder.setTitle("title");
builder.setMessage("message");
builder.setPositiveButton("Reprendere", null);
builder.setNegativeButton("Plus Tard", null);
builder.show();
于 2012-11-09T12:54:50.993 回答
0

用这个 :

AlertDialog anAlertDialog = new AlertDialog.Builder(getParent()).create();
                    anAlertDialog.setTitle("");
                    anAlertDialog.setMessage("Are you sure you want to logout!");
                    anAlertDialog.setButton("OK", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {

                            return;
                        }
                    });
                    anAlertDialog.setButton2("CANCEL", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {

                        }
                    });
                    anAlertDialog.show();
于 2012-11-09T13:09:58.290 回答