Is there a method like setResult() in fragment?

前端 未结 4 1091
粉色の甜心
粉色の甜心 2021-02-18 13:02

I am using a fragment. I am getting an error in the onResult() method. I need a substitute method for setResult(RESULT_OK, data) that I can use in my f

4条回答
  •  暖寄归人
    2021-02-18 13:30

    You should call it on your fragment owning activity:

     getActivity().setResult(Activity.RESULT_OK, data) 
    

    also you might want to finish your activity:

     getActivity().finish();
    

提交回复
热议问题