1. Are you ready for the Galaxy S20? Here is everything we know so far!

Fragments Displaying other Fragments

Discussion in 'Android Development' started by Abstract3000, Feb 14, 2016.

  1. Abstract3000

    Abstract3000 Lurker
    Thread Starter

    Hello,

    So I am Very new to the entire android thing, and I'm currently working on developing a unique app. In doing so I am trying to find the best way to implement it and wanting to know if my topic is in fact possible. So for a bit more specifics this is what I am wanting to do but unsure if I can:

    Consider an Activity with 2 Fragments we will call them Top_1 & Bottom_1, now Bottom_1 will remain on the bottom half of the screen at all times first appearing with Top_1. Through Button/Spinner Listener in Bottom_1 I want to be able to display different Fragments, such as Top_2, Top_3, Top_4 etc. all the while keeping Bottom_1 intact.

    At this given moment I am just looking to see if this is possible to do, as I have created a two Fragment activity, and from what I learned I'm having difficulty grasping in how I would call to the other Fragments and have them replace the top.

    Thanks for your consideration.
     


  2. Deleted User

    Deleted User Guest

    Yes indeed. It's why fragments were introduced - to make it possible to create modular, composite screens with dynamic content. It also allows great code reuse, and promotes good software architecture. Fragments also have a lifecycle very similar to Activities, and you can add them to the back stack - so the back button works, if you want that behaviour.
    I think all this fits in with what you want to achieve. In fact I'm doing something very similar myself right at the moment, creating a screen which has distinct parts, which can vary, depending on the user input. It's possible to replace a container element with a different Fragment, dynamically. There are lots of code examples of how to do this.
    Fragments are the way to go!
     
  3. Abstract3000

    Abstract3000 Lurker
    Thread Starter

    Thanks for the Reply Much appreciated, I might need some help getting it fully working, but let me work on the code some and see what I can make happen first, then If I need help in quirking the code I'll be back :)
     
Loading...
Similar Threads - Fragments Displaying Fragments
  1. Nitrogen247
    Replies:
    0
    Views:
    251
  2. adrem7
    Replies:
    0
    Views:
    260
  3. anwartan
    Replies:
    0
    Views:
    444
  4. maheshkulkarni
    Replies:
    0
    Views:
    208
  5. naighz
    Replies:
    0
    Views:
    256
  6. LordJavaNoob
    Replies:
    0
    Views:
    360
  7. RioLeal
    Replies:
    1
    Views:
    368
  8. Guitarist
    Replies:
    0
    Views:
    360
  9. RioLeal
    Replies:
    6
    Views:
    1,021
  10. curtis1997
    Replies:
    0
    Views:
    490

Share This Page

Loading...