If I declare a fragment in an XML layout, how do I pass it a Bundle?

前端 未结 6 790
南笙
南笙 2020-12-01 12:01

I\'ve got an activity that I\'ve replaced with a fragment. The activity took an Intent that had some extra information on what data the activity was supposed to display.

6条回答
  •  我在风中等你
    2020-12-01 12:02

    The only solution I see is to not use the arguments as data exchange channel. Instead, make your fragment to obtain the necessary information from elsewhere. Call back to get the proper activity, consult a temporary storage memory, a Singleton object, etc..

    Another solution that can be helpful is to employ frameworks that allow unrelated objects to exchange messages via Mediator design pattern, as Otto.

提交回复
热议问题