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

  • SEARCH
  • Home
  • 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 9067959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T17:04:29+00:00 2026-06-16T17:04:29+00:00

I am working on my first android app so forgive me if this is

  • 0

I am working on my first android app so forgive me if this is a simple question. The app currently has five tabs (made using fragments) and I am currently trying to set up a ListFragment in the first tab.

In my MainActivity class I have the code:

public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
    if (tab.getPosition() == 0) {
        TopRatedListFragment topRatedListFragment = new TopRatedListFragment();
        getSupportFragmentManager().beginTransaction().replace(R.id.container, topRatedListFragment).commit();
    } else {
        Fragment fragment = new DummySectionFragment();
        Bundle args = new Bundle();
        args.putInt(DummySectionFragment.ARG_SECTION_NUMBER, tab.getPosition() + 1);
        fragment.setArguments(args);
        getSupportFragmentManager().beginTransaction().replace(R.id.container, fragment).commit();
    }

Now this works fine for my “DummySectionFragment”s. But my TopRatedListFragment extends ListFragment instead of just Fragment… so therefore the above code is giving me issues.

The line:

getSupportFragmentManager().beginTransaction().replace(R.id.container, topRatedListFragment).commit();

is the one drawing the error and saying the .replace method doesn’t like the topRatedListedFragment argument since it is a ListFragment and not a regular Fragment.

How should I fix this?

Thanks!

  • 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-16T17:04:30+00:00Added an answer on June 16, 2026 at 5:04 pm

    Most likely, your imports and/or class definitions are messed up.

    There are two implementations of Fragment, ListFragment, and FragmentTransaction. One set is in android.app. The other set is in android.support.v4.app. These are not compatible. You use the latter pair if you are using FragmentActivity for the Android Support package’s backport of fragments.

    My guess is that your FragmentTransaction and your ListFragment are coming from different packages, one from android.app and one from android.support.v4.app. If so, you need to fix that, having both use the same package, whichever one is appropriate for your circumstances.

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

Sidebar

Related Questions

So I'm making my first Android app, using ADT in Eclipse and working with
I am currently working on my first android app. In a listview, I need
I'm working on my first Android app, and am almost to the point where
I'm very new to java and am working on my first Android app. I
Hello and thanks for looking. I am working on my first android app. In
I have some contacts autocomplete and autosearch algorithm working for my android app. First
To begin with, this is the first Android app I'm writing, and I have
First time working with android. I'm look for a way that an android app
I'm working on an android app where I have only 2 activities... The first
I've been working on an Android App that has already been published to Google

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.