Android examples for android.app:Activity
add Fragment To Activity
import android.support.annotation.NonNull; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction; public class Main{ public static void addFragmentToActivity( @NonNull FragmentManager fragmentManager, @NonNull Fragment fragment, int frameId) { FragmentTransaction transaction = fragmentManager .beginTransaction();//from w ww. jav a 2 s .c om transaction.add(frameId, fragment); transaction.commit(); } }