我的DialogFragment中有下一个代码:
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Log.i(getClass().getName(), "onCreateDialog");
final FileSystemAdapter adapter = getAdapter();
adapter.showFS(null);
AlertDialog b = new AlertDialog.Builder(getActivity())
.setTitle(title)
.setCancelable(false)
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
//some actions
}
})
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dismiss();
}
})
.setAdapter(adapter, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
adapter.showFS(adapter.getItem(i));
}
})
.create();
return b;
}
单击列表元素后,调用最后一个onClick方法,然后关闭对话框。
如何防止这种行为并保持对话框打开,直到调用解除方法?