android - Is the Official Fragment Developer Guide Contradicting itself? -


In the section of

, it says:

You must assign each piece to a modular and : This is the usable activity component, because each piece defines its behavior with its own layout and its own lifecycle callback, you can include a piece in several activities, so that you should design for reuse and Straight from one piece to another Avoid tampering

But in this, Title Fragment class (expanded ListFragment ) directly DetailsFragment refers to the showDetails () method in the class ( fragment ) in the findFragmentById ()

 < Code> DescriptionFragment Description = (DescriptionFilmment) getFragmentManager (). FindFragmentById (R.id.details);   

and calling descriptionfamily newInstance () method of class.

  Description = descriptionfragment.newense index);   

Is this a bad coding style?

Comparatively, the coding style looks better, it uses the interface for fragment-to-activity communication.

Is this a bad coding style?

IMHO, yes, IMHO, one piece should neither be known nor take care of other pieces managed by the activity. One piece can focus on the piece of the baby through the nested pieces ( getChildFragmentManager () , but not the potential piece pieces.

In the case of an example, the Title Fragment should not be ignored, it is shown in single-pane or double-pane mode. The activity should be kept in mind that all screen-size- Separates Assurance Code - Title The fragment can be unaware of the screen size.

It is being said that the code is not technically incorrect with AFAIK - it's not just how I advised to do this

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -