我正在处理一个单击按钮后调用对话框片段的片段。问题是,一旦我想在对话框片段中传递参数,它就会返回一个空参数。我该如何解决这个问题?
片段
mSaveBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SaveProductDialog saveProductDialog = SaveProductDialog.newInstance(mAddProductPresenter, String.valueOf(getmProductName().getText());
saveProductDialog.show(getFragmentManager(), "SaveProduct");
}
DialogFrament
public static SaveProductDialog newInstance(Presenter presenter, String productName){
SaveProductDialog saveProductDialog = new SaveProductDialog();
Bundle args = new Bundle();
args.putSerializable(ARGS_PRESENTER, presenter);
args.putString(ARGS_PRODUCT_NAME, productName);
saveProductDialog.setArguments(args);
return saveProductDialog;
}
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
//This returns an empty string instead of the presenter object
AddProductPresenter addProductPresenter = (AddProductPresenter) getArguments().getSerializable(ARGS_PRESENTER);
}
如果您需要有关我的代码的更多详细信息,请与我们联系。谢谢!