添加快速滚动到AlertDialog.Builder卷轴

cai*_*ain 4 android dialog fastscroll

我有一个很大的用户列表在AlertDialog中显示为选择列表.这是我用来生成它的代码:

 AlertDialog.Builder builder = new AlertDialog.Builder(thisContext);
                    builder.setTitle("User");
                    builder.setItems(userNames, new  DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int pos) {
                        //selection processing code

                }});
                builder.setNeutralButton("Clear", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                        //clear processing code
                    }});
                builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {

                    }
                });
                dialog=builder.create();
                //next line added as solution
                dialog.getListView().setFastScrollEnabled(true); 
                dialog.show();
Run Code Online (Sandbox Code Playgroud)

userNames是数据库中的一个alphebetical名称列表.

然而,这在大多数情况下非常有效,因为我有超过100个或更多用户,滚动列表有点慢.如何添加快速滚动以便用户可以在需要时跳转到列表中的某个部分?

MH.*_*MH. 10

您是否尝试过调用AlertDialog?getListView().setFastScrollEnabled(true)