You should use Fragment
from the support library.
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
You also need to use getSupportFragmentManager()
and since you are using AppCompat
your activity must extend ActionbarActivity
.
FragmentManager fragmentManager = getSupportFragmentManager();
Update:
ActionBarActivity
is deprecated use AppCompatActivity
from support library. Don't forget to update your support repository to the latest.