我有一个很大的用户列表,作为选择列表显示在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();
用户名是数据库中名称的一个重要列表。
不过,这在大多数情况下都很有效,因为我有100多个用户,滚动列表有点慢。如何添加快速滚动,以便用户可以在需要时跳转到列表的下一部分?
最佳答案
你试过在AlertDialog上拨打getListView()
.
setFastScrollEnabled(true)
吗?