You are on page 1of 3

Value Added Program

(Fragments)

AIM :- To perform fragment program

Pre Requsite :- Android Studio

Code :-

/*Fragment1.java*/

package com.example.fragments;

import android.content.Context;

import android.net.Uri;

import android.os.Bundle;

import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;

import android.view.View;

import android.view.ViewGroup;

public class Fragment1 extends Fragment {

private static final String ARG_PARAM1 =


"param1";

private static final String ARG_PARAM2 =


"param2";

public Fragment1() {

@Override

public View onCreateView(LayoutInflater inflater,


ViewGroup container,

Bundle savedInstanceState) {

return inflater.inflate(R.layout.fragment_fragmen-
t1, container, false);

/*Fragment2.java*/

package com.example.fragments;

import android.content.Context;

import android.net.Uri;

import android.os.Bundle;

import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;

import android.view.View;

import android.view.ViewGroup;

public class Fragment2 extends Fragment {

private String mParam1;

private String mParam2;

public Fragment2() {

@Override

public View onCreateView(LayoutInflater inflater,


ViewGroup container,

Bundle savedInstanceState) {

// Inflate the layout for this fragment

return inflater.inflate(R.layout.fragment_fragmen-
t2, container, false);

OUTPUT :-

You might also like