Add quick scroll to scroll AlertDialog.Builder

I have a large list of users displayed in AlertDialog as a selection list. This is the code I use to create it:

 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();

userNames is an algebraic list of names from the database.

This works very well for the most part, however, since I have more than 100 or more users, scrolling through the list is a bit slower. How can I add quick scrolling so that users can jump to the next part of the list if necessary?

+3
source share
1 answer

Have you tried calling in AlertDialog?getListView() . setFastScrollEnabled(true)

+9
source

All Articles