I am using the code from the link.
When I paste this code into my program, I get an error message as shown in the figure below. 
Any reasons for the error? The method replace(int, Fragment) in the type FragmentTransaction is not applicable for the arguments (int, ExampleFragments)
Code from my main activity:
public void red(View view) { android.app.FragmentManager fragmentManager = getFragmentManager(); android.app.FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); ExampleFragments fragment = new ExampleFragments(); fragmentTransaction.replace(R.id.frag, fragment); fragmentTransaction.commit(); }
ExampleFragments.java
package com.example.learn.fragments; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; public class ExampleFragments extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Here:
package com.example.learn.fragments; import android.app.Activity; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction; import android.view.LayoutInflater; import android.view.Menu; import android.view.View; import android.view.ViewGroup;
java android android-fragments
EGHDK Jul 23 '12 at 19:58 2012-07-23 19:58
source share