place Fragment On Layout - Android User Interface

Android examples for User Interface:Fragment

Description

place Fragment On Layout

Demo Code


//package com.java2s;
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentTransaction;

public class Main {
    public static void placeFragmentOnLayout(
            android.support.v4.app.FragmentActivity activity,
            android.support.v4.app.Fragment fragment, int containerId,
            String tag) {//from ww  w  .j a  va 2  s . co  m
        android.support.v4.app.FragmentTransaction transaction = activity
                .getSupportFragmentManager().beginTransaction();
        transaction.add(containerId, fragment, tag);
        transaction.commit();
    }

    public static void placeFragmentOnLayout(Activity activity,
            Fragment fragment, int containerId, String tag) {
        FragmentTransaction transaction = activity.getFragmentManager()
                .beginTransaction();
        transaction.add(containerId, fragment, tag);
        transaction.commit();
    }
}

Related Tutorials