I have a large list of users being displayed in an AlertDialog as a selection list. This is the code I am using to generate 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 alphebetical list of names from the database.
This works very well for the most part, however, because I have over 100 or more users, scrolling through the list is a little slow. How can I go about adding fast scroll so that the users may be able to jump to a part further down in the list when needed?
Have you tried calling getListView()
.
setFastScrollEnabled(true)
on the AlertDialog?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With