@blog.justoneplanet.info

日々勉強

fragmentに値を渡す

■渡す側

FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();

SearchFragment fragment = (SearchFragment) Fragment.instantiate(getActivity(), SearchFragment.class.getName(), null);
Bundle bundle = new Bundle();
bundle.putString("word", word);
fragment.setArguments(bundle);

ft.replace(R.id.content, fragment).addToBackStack("result");
ft.commit();
getActivity().getSupportFragmentManager().executePendingTransactions();

■受け取り側

mWord = getArguments().getString("word");

コメントはまだありません»

No comments yet.

RSS feed for comments on this post.TrackBack URL

Leave a comment