Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8339337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:51:31+00:00 2026-06-09T04:51:31+00:00

Im trying to switch fragments using the example here: http://developer.android.com/guide/components/fragments.html But it does not

  • 0

Im trying to switch fragments using the example here:

http://developer.android.com/guide/components/fragments.html

But it does not work:

Fragment newFragment = new ExampleFragment();
        android.app.FragmentTransaction transaction = getFragmentManager().beginTransaction();
        transaction.replace(android.R.id.content, newFragment);
        transaction.addToBackStack(null);
        transaction.commit();

I get the error:

The method replace(int, Fragment) in the type FragmentTransaction is not applicable for the arguments (int, Fragment)

So I fix this with:

android.app.Fragment newFragment = new ExampleFragment();
        android.app.FragmentTransaction transaction = getFragmentManager().beginTransaction();
        transaction.replace(android.R.id.content, newFragment);
        transaction.addToBackStack(null);
        transaction.commit();

and get another error saying that ExampleFragment has teh wrong type, so I change it to:

 ExampleFragment newFragment = new ExampleFragment();
        android.app.FragmentTransaction transaction = getFragmentManager().beginTransaction();
        transaction.replace(android.R.id.content, newFragment);
        transaction.addToBackStack(null);
        transaction.commit();

And it all just keeps going round in loops, whats the fix?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T04:51:33+00:00Added an answer on June 9, 2026 at 4:51 am

    You need to add the support library to the project. That should fix your issues. Undo the code changes you made… and in eclipse, right click (or option click depending on your machine) the project and go to Android Tools > Add Support Library…

    Clean and rebuild the project… should fix all your errors.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to switch over to using HAML for my views but I keep
I'm trying to implement a tab bar with fragments and RadioGroup i switch fragments
I'm trying to switch over to using app.yaml instead of web.xml and app-engine-web.xml. I've
I'm really trying to switch to emacs, but learning to setup the environment is
When trying to use a Switch Case with switch(string) for an android project ,
I'm trying to switch views in an iPhone application, but whenever I click on
I'm trying to switch local branches in GIT but some auto-generated, ignored and uncommitted
I trying to switch my mysql database to different location. But i could not
I'm trying to switch to pdo and have enjoyed success with it but my
I'm trying to switch back from my UIViewController to my UITableViewController but apperendly it's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.