AlertDialog 标题居中


AlertDialog.Builder alert = new AlertDialog.Builder(this)

                 .setMessage("确定吗?")
                 .setPositiveButton(R.string.OK, new DialogInterface.OnClickListener() {
                     public void onClick(DialogInterface dialog, int id) {
                     }
                 })
                 .setNegativeButton(R.string.back, new DialogInterface.OnClickListener() {
                     public void onClick(DialogInterface dialog, int id) {
                         dialog.cancel();
                     }
                 });


        TextView title = new TextView(this);
        title.setGravity(Gravity.CENTER);
        title.setBackgroundResource(R.drawable.list);
        title.setText("确定");

        alert.setCustomTitle(title);

alert.show();

猜你喜欢

转载自blog.csdn.net/subofeng/article/details/54582446