我正在打开一个对话框,以便我的用户可以从列表中选择一年。
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle("Choose Year")
.setItems(years, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// The 'which' argument contains the index position
// of the selected item
}
});
return builder.create();
years
变量是String[]
但最长可达100个项目。有没有办法让Dialog打开显示可见初始范围列表中的特定项目?例如,如果年份的数组从1913年到2013年,那么它总是打开到1913年。无论如何在1980年的列表中间打开它?
答案 0 :(得分:0)
尝试在DialogFragment的onCreateView方法中使用ListView扩展布局。