Savage F. Morgan

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

Make a bundle object and insert your data (in this example your Category object). Be careful, you can't pass this object directly into the bundle, unless it's serializable. I think it's better to build your object in the fragment, and put only an id or something else into bundle. This is the code to create and attach a bundle:

Bundle args =newBundle();
args.putLong("key", value);
yourFragment.setArguments(args);

After that, in your fragment access data:

Type value = getArguments().getType("key");

That's all.

reference link:http://stackoverflow.com/questions/12062946/why-do-i-want-to-avoid-non-default-constructors-in-fragments

posted on 2013-02-07 15:49  罗斯摩根  阅读(1947)  评论(1编辑  收藏  举报