How to clear arguments in Fragment?

后端 未结 5 1488
Happy的楠姐
Happy的楠姐 2021-02-20 01:58

I have an AudioPlayerFragment to which I pass some url with setArguments().

If I have an url key in the getArguments() of my insta

5条回答
  •  长情又很酷
    2021-02-20 02:11

    I have come across situations where you want to remove the arguments in a fragment. for example, entering a fragment for the first time maybe you have up to date data, but afterwards on a fragment re-creation you do not want that data, you want to refresh. you could clear a element in the bundle like this:

    getArguments().remove("cartDetails");
    

    for my case i wrote about, i put that in onCreate of the fragment after getting the initial data.

提交回复
热议问题