public class MyFragmentActivity extends FragmentActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Set layout file setContentView(R.layout.activity_main); } }
public class MyDialogFragment extends DialogFragment { @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // Set custom layout for the dialog fragment View view = inflater.inflate(R.layout.dialog_layout, container, false); // Return the inflated view return view; } }The package library used in the code examples is android.support.v4.app. This package provides compatibility for older Android versions and includes classes like Fragment, FragmentManager, FragmentTransaction, etc.