use of com.andframe.listener.SafeListener in project AndFrameWorks by scwang90.
the class AfDialogBuilder method selectItem.
/**
* 显示一个单选对话框
*
* @param title 对话框标题
* @param items 选择菜单项
* @param listener 选择监听器
* @param oncancel 取消选择监听器
*/
@Override
public Dialog selectItem(CharSequence title, CharSequence[] items, OnClickListener listener, final OnCancelListener oncancel) {
Builder dialog = new Builder(mContext);
if (title != null) {
dialog.setTitle(title);
if (oncancel != null) {
dialog.setNegativeButton("取消", new SafeListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
oncancel.onCancel(dialog);
}
});
}
}
if (oncancel != null) {
dialog.setCancelable(true);
dialog.setOnCancelListener(new SafeListener(oncancel));
} else {
dialog.setCancelable(false);
}
dialog.setItems(items, new SafeListener(listener));
return dialog.show();
}
Aggregations