0% found this document useful (0 votes)
32 views3 pages

Value Added (Fragment)

This document discusses how to perform fragment programming in Android Studio. It requires Android Studio as a prerequisite. It provides code for two fragment classes called Fragment1 and Fragment2 that extend the Fragment class and override the onCreateView method to return a view for each fragment. The code demonstrates how to create basic fragments in an Android application.

Uploaded by

K. J kartik Jain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views3 pages

Value Added (Fragment)

This document discusses how to perform fragment programming in Android Studio. It requires Android Studio as a prerequisite. It provides code for two fragment classes called Fragment1 and Fragment2 that extend the Fragment class and override the onCreateView method to return a view for each fragment. The code demonstrates how to create basic fragments in an Android application.

Uploaded by

K. J kartik Jain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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