简体   繁体   English

向后调用和onActivityResult()不在Fragment中调用,但在活动中调用

[英]Backward calls and onActivityResult() not calling in Fragment but calls in activity

I have A activity. 我有活动。 This contain 4 Fragments. 这包含4个片段。 I created separated Fragment class in other packages. 我在其他程序包中创建了单独的Fragment类。 so A activity contain 4 Fragments. 因此一个活动包含4个片段。 one of them is B fragment. 其中之一是B片段。 Now B Fragment calls to Activity C by startActivityForResult. 现在,B片段通过startActivityForResult调用ActivityC。 so i writes the method onActivityResult in B Fragment. 所以我在B Fragment中写了onActivityResult方法。 But same method is also in Activity A which is most important and can't be remove. 但是,活动A中也使用了相同的方法,这是最重要的,无法删除。 Now when I came back from C -- > B then onActivityResult is not calling but activity A's onActivityResult calls. 现在,当我从C-> B返回时,onActivityResult不是在调用,而是活动A的onActivityResult在调用。 so how can i call to this method in (B)fragment too. 所以我也该如何在(B)片段中调用此方法。 so i can change the data by calling it. 所以我可以通过调用它来更改数据。

Try to call 尝试致电

super.onActivityResult();

in your Activities onActivityResult() to pass the Callback to your Fragment. 在您的Activity onActivityResult()中将回调传递给您的片段。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 片段onActivityResult方法执行调用活动onActivityResult - Fragment onActivityResult method on executing calls activity onActivityResult 从片段调用setHasOptionsMenu(true)会导致对Activity中的onCreateOptionsMenu进行多次调用 - Calling setHasOptionsMenu(true) from a fragment results in multiple calls to onCreateOptionsMenu in Activity 从活动中的片段中调用一个物品 - Calls an Item from Fragment in Activity 子活动调用finish()后未调用onActivityResult - onActivityResult is not been invoked after the child activity calls finish() 超级OnActivityResult不调用Fragment OnActivityResult - Super OnActivityResult not calling Fragment OnActivityResult 当Activity调用Fragment但不调用ListFragment时,最简单的代码起作用 - Simplest code working when Activity calls Fragment but not when it calls ListFragment onActivityResult 从 Activity 到 Fragment - onActivityResult from Activity to Fragment 创建片段之前在活动中执行网络呼叫 - Performing network calls in activity before creating fragment 开始片段会调用活动的onCreate() - Starting a fragment calls activity's onCreate() 回到调用另一个活动的片段 - Getting back to the fragment which calls another activity
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM