android-如何更改alertdialog项目的引力

时间:2014-09-07 07:54:23

标签: android android-alertdialog android-dialog

这是我的警告对话:

                AlertDialog.Builder builder = new AlertDialog.Builder(NewCar.this);
                builder.setTitle("Make your selection");
                builder.setItems(items, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int item) {
                       Log.v("this",items[item]+ " ");
                    }
                });
                AlertDialog alert = builder.create();
                alert.show();
                TextView titleView = (TextView)alert.findViewById(getResources().getIdentifier("alertTitle", "id", "android"));
                if (titleView != null) {
                    titleView.setGravity(Gravity.RIGHT);
                }

这是输出:

enter image description here

正如您所看到的,标题是从右到左,但我也无法将项目从右到左。

如何让物品从右向左移动?

谢谢你

1 个答案:

答案 0 :(得分:1)

在xml(或代码中)创建自定义视图并使用

builder.setView(customView)