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 8640099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:11:47+00:00 2026-06-12T11:11:47+00:00

I have a layout file containing a listview that I would like to fill

  • 0

I have a layout file containing a listview that I would like to fill with the help of a Fragment. But it continues to give me errors.
The layout file:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<ListView
    android:id="@+id/list"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true" >
</ListView>

<TableLayout
    android:id="@+id/details"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:stretchColumns="1" >

    <Button
        android:id="@+id/create_patient_button"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/create_patient_button" />
</TableLayout>

</RelativeLayout>

My fragmentActivity:

public class BasicFragmentActivity extends FragmentActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);


    setContentView(R.layout.create_patient_view);

    FragmentManager fm       = getSupportFragmentManager();
    Fragment        fragment = fm.findFragmentById(R.id.list);

    if (fragment == null) {


        FragmentTransaction ft = fm.beginTransaction();
        ft.add(R.id.list, new BasicFragment());
        ft.commit(); // Make sure you call commit or your Fragment will not be added. 
                     // This is very common mistake when working with Fragments!
    }
}

}

My ListFragment:

public class BasicFragment extends ListFragment {

private PatientAdapter pAdapter;

@Override
public void onActivityCreated(Bundle savedState) {
    super.onActivityCreated(savedState);

    pAdapter = new PatientAdapter(getActivity(), GFRApplication.dPatients);
    setListAdapter(pAdapter);
}
}

The error:
java.lang.UnsupportedOperationException: addView(View) is not supported in AdapterView

  • 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-12T11:11:48+00:00Added an answer on June 12, 2026 at 11:11 am

    findFragmentById(...) function takes ID of fragment(!) as parameter. But you call it with R.id.list which is ID of ListView (<ListView android:id="@+id/list" ...). It’s wrong because ListView is NOT a fragment. It’s the first problem.

    The second problem is:

      FragmentTransaction ft = fm.beginTransaction();
           ft.add(R.id.list, new BasicFragment());
    

    in ft.add() function first parameter is ID of container in which you want to put your fragment. But you use R.id.list which is id of your ListView. It is wrong because ListView is not a container in which you can put fragments directly.

    If you want put fragments into ListView items you can:

    1. fill ListView with custom views.
    2. declare <fragment ...> into custom view layout (XML). Or create fragment container in custom view layout (FrameLayout for example) and put there fragment at runtime (in getView() method).
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a text file containing 10 columns of numbers. What I would like
I only have a ListView containing TextView. I would like to add an image
I have custom component that I can place in my layout file (XML) for
So I have a layout that is a separate file, so I inflate it.
I have a text file that has the following layout: text text .. CUT
I have a file system containing PNG images. The layout of the filesystem is:
I have an activity MyActivity that extends from MapActivity. In the .xml file containing
Setup I have an accordion layout containing a properties panel that nests two inner
i am designing an app for android tablets. I have created a layout file
I have the following XML layout file, HELPME.XML <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent

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.