我在关闭DialogFragment并返回到Activity的onActivityResult时遇到问题。
下面是我的代码,它调用DialogFragment。
Bundle args = new Bundle();
args.putString("cliente", hashtableFiltros.get("cliente"));
args.putString("produto", hashtableFiltros.get("produto"));
args.putString("dataInicio", hashtableFiltros.get("dataInicio"));
args.putString("dataFim", hashtableFiltros.get("dataFim"));
args.putInt("valorMin", Integer.parseInt(hashtableFiltros.get("valorMin")));
args.putInt("valorMax", Integer.parseInt(hashtableFiltros.get("valorMax")));
android.support.v4.app.FragmentManager fm = getSupportFragmentManager();
FiltroPedidos dialogFragment = new FiltroPedidos();
dialogFragment.setArguments(args);
dialogFragment.show(fm, "FiltroPedidos");
在单击DialogFragment的PositiveButton之后,必须输入requestCode并返回到Activity。
Intent intent = new Intent(view.getContext(), PedidosFragment.class);
intent.putExtra("cliente", "");
getActivity().startActivityForResult(intent, 5);
返回此状态是Activity中的onActivityResult。
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (data != null) {
if (requestCode == 5) {
}
}
可能是什么问题?因为它关闭了DialogFragment,但是没有转到onActivityResult。