我有一个很大的用户列表作为选择列表显示在 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();
userNames 是数据库中姓名的字母顺序列表。
这在大多数情况下都非常有效,但是,因为我有超过 100 个或更多的用户,所以滚动列表有点慢。我如何才能添加快速滚动,以便用户可以在需要时跳转到列表中更靠下的部分?
最佳答案
你试过调用getListView()
吗? 。
setFastScrollEnabled(true)
在 AlertDialog 上?
关于android - 将快速滚动添加到 AlertDialog.Builder 滚动列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10692284/