Search code examples
javaandroidlayoutbottomnavigationview

How to add another Screen inside a Fragment?


I'm new to Android programming, and I have some questions about what type of layout to use. I am developing an application and have already done a basic mock-up of the interaction I want the user to have.

Following some tutorials I managed to build an app with a Bottom Navigation Bar with 3 Fragments, each one with it's own view. But my goals is that when the user clicks a button on one of these Fragments, the application opens a new View on the same Fragment.

What is the best way to achieve this goal? I have attached an image of the mock-up I made below, hope it helps to clarify the question. Thank you in advance for taking the time to help me!

Link to the mock-up app


Solution

  • That's sounds like you want to start a new Activity.

    Considering you have your fragments in CurrentActivity and you want to start InvokingActivity

    On clicking button in CurrentActivity

    onClickMethod(View v){
       Intent intent = new Intent(CurrentActivity.this, InvokingActivity.class)
       //put some extras if you like
       startActivity(intent)
    }
    

    To get arrow in top left corner you need to update AndroidMainfest by adding to InvokingActivity

     android:parentActivityName="CurrentActivity"