converting activity into fragment

后端 未结 4 860
一个人的身影
一个人的身影 2020-11-27 13:11

This is a simple code to play a sound on click off a button, this code was initially written in Activity but now i want to change it to Fragments.

erro

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-27 14:12

    Use this code in overriden method OnActivityCreated(...) and instead of this use getActivity(), since new fragment is not activity any more.

提交回复
热议问题