1

构造函数(注意 ListPickerHandler)

public StarredListPickerDialogFragment(ListPickerHandler h) {
        handler = h;
        mSelectedItems = new ArrayList<StarredList>();
    }

这就是我调用父片段方法的方式(定义实现 ListPickerHandler 接口)

 alertDialog.setOnShowListener(new DialogInterface.OnShowListener() {
            @Override
            public void onShow(DialogInterface dialog) {
                Button negative = alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE);
                Button positive = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
                positive.setEnabled(false);
                negative.setOnClickListener(new View.OnClickListener() {

                    @Override
                    public void onClick(View view) {
                        handler.onNegativeButtonAction(mSelectedItems);
                    }
                });
                positive.setOnClickListener(new View.OnClickListener() {

                    @Override
                    public void onClick(View view) {
                        handler.onPositiveButtonAction(mSelectedItems);
                    }
                });
            }
        });

现在,当 android os 调用 onSaveInstanceState() 时,麻烦就来了。处理程序不再定义,我实际上没有线索来处理这种情况..

4

1 回答 1

0

通过将父片段转换为 ListPickerHandler(当 bundle 不为 null 时)来解决,ListPickerHandler 是调用片段实现的接口

于 2013-03-28T07:52:03.057 回答