Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6749983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:45:17+00:00 2026-05-26T12:45:17+00:00

Docs say you shouldn’t nest fragments ’cause they are designed to work another way.

  • 0

Docs say you shouldn’t nest fragments ’cause they are designed to work another way. But!

Scope

But what if I use ViewPager and it’s fragment (visible screen) should be constructed from other fragments. Let’s say we have a messenger app. On the main screen there’s a ViewPager with fragment called "Last messages" (MessagesFragment) and on the submain screen (let’s say Discussion or Chat room) we also have a ViewPager but Messages screen consists of MessagesFragment, NewMessageBarFragment and e.g. header fragment with other info.

Problem

One can say we shouldn’t use ViewPager for that and we can use ViewFlow open source library but believe me the code, holded in such activity is a mess even with fragments. Also there’s an approach to fill extra layouts, not fragments for NewMessageBar and HeaderInfo within MessagesFragment — but it’s double ugly as for me.

Question

Is it OK to use nested fragments in this particular situation? What would you recommend?

Upadate

Sometimes it’s really ‘must have’ feature. But! In most cases I would recommend follow ‘responsive design’ way: http://www.slideshare.net/kirillcool/responsive-mobile-design-in-practice

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T12:45:18+00:00Added an answer on May 26, 2026 at 12:45 pm

    But what if I use ViewPager and it’s fragment (visible screen) should be constructed from other fragments.

    Don’t do that.

    Is it OK to use nested fragments in this particular situation?

    Absolutely not.

    What would you recommend?

    Replace your “outer” fragments with simple layouts. Then use some other PagerAdapter implementation that does not itself require a fragment (as does the FragmentPagerAdapter interface). You may need to pinch some code from FragmentPagerAdapter to make sure this all works well.

    Or, combine “MessagesFragment, NewMessageBarFragment and e.g. header fragment with other info” into a single fragment for use on screen sizes where you want to have this pager behavior. This may result in some amount of code duplication, to have that portion of the UI broken out separately for smaller screen sizes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

MSDN docs say that only value types need boxing, but this does not apply
The Speex docs say that it's 'mainly' designed for 8/16/32kHz sampling rates. Most PC
As docs say it's impossible to add two menu items to NSPopUpButton if they
The docs say: Contact Synchronization is performed by the Synchronization service. The service loops
The docs say: If not all the certificates needed to verify the leaf certificate
The Python docs say: re.MULTILINE: When specified, the pattern character '^' matches at the
The Django docs say this on the subject: Note also that Django stores signal
Section 7.1.6 of the Modeshape docs say 'Your application can now create and remove
I've been using seesaw.tree/simple-tree-model to create my TreeModels, the docs say that this is
The docs simply say or define custom schema (non-juggling), for example, mongoose. Please note,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.