There are many fragments, for example, take test and test2 .
I called test , in which there is a ListView , by clicking on which the add item window opens ( fragmentadd ), but before showing fragmentadd , I set all test elements in the test fragment to enadled = false - i.e. they became inactive.

In fragmentadd entered the name and clicked OK - now I need to unlock all the elements of the test fragment. Unlocked, like by clicking on the OK button, I got a snippet:

 getFragmentManager().findFragmentByTag(getString("test)); 

I received it View and set it already enadled = true , but other fragments also apply to the fragmentadd fragmentadd - there are 20 of them. Can't I look for 20 other fragments while I'm alone?

I wanted to pass either setArguments() or a fragment, or its getView() , but it did not work out.

Tell me, how can I send a link to it or its getView() in the fragment?

  • Those. You from all 20 fragments call one fragment and want to catch the return event on it in the launch fragment? If yes, then you need setTergetFragment and onActivityResult - YuriiSPb
  • I need in that one fragment to have a link to the View of the calling fragment. - Ivan
  • one
    This is a vicious practice if you need to actually change the state of a fragment show / hide event. You just need to catch these events. One fragment should not know anything about the other. Especially to have a link to its markup. This is the source of a host of issues - YuriySPb
  • Just need from the second fragment to access the view from the first. - Ivan
  • one
    Both fragments simultaneously displayed on the screen? If not, your whole undertaking is doomed to failure and torment. And why do we need to block the View in the fragment? - pavlofff

1 answer 1

It is still not very clear why you should block / unblock something. While fragment B is running, you cannot click on something in fragment A without closing B. This is if fragment B is a dialog. If there is no dialogue, then at the time of launch B, block the interface in A, and after closing B, after catching this event, unlock A described in the first comment. You can implement locking / unlocking methods in the basic abstract fragment and inheriting all other A type fragments from it . So you and the code will not be duplicated and problems with prokidyvanie links to the View will not be

  • If fragment B is smaller in size. And then I can click on fragment A with B. I active and try to block the view at the time B. is started. In the first koment, I only get iskuchenie.So I did not duplicate the static code function. Now. After closing B, send something in A to catch onActivityResult and unblock it. But for some reason, that's the exception. That's all. GetTargetFragment (). OnActivityResult (getTargetRequestCode (), Activity.RESULT_OK, null); says and that's it. What's wrong? - Ivan
  • @Ivan, show the code and the exact line of the drop. Probably you forgot to indicate something somewhere - YuriySPb
  • So I did not add it. The error was in setTargetFragment. I called setTargetFragment (this, 1); anuzhno test2.setTargetFragment (this, 1); I would like to use the lock function as static or You can implement the lock / unlock methods in the basic abstract fragment and inherit all other type A fragments from it? I’ll just create a class with static functions. 20 pieces will enter. Not yet to shove a fragment? - Ivan
  • @Ivan, I would do that - in the base fragment I would redefine onActivityResult to include views. And in B, I would make a static method for launching this fragment with A as an argument. It is possible to cause a shutdown of views in A and the establishment of a target for B fragment - YuriySPb
  • one
    Probably I will create a fragment in which I will store the necessary functions for the operation of the application. Then all fragments will inherit from it. I think this will work. - Ivan