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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:32:10+00:00 2026-05-26T01:32:10+00:00

I ve two ListFragments maganed by a tabhost. Firt time I switch between tab

  • 0

I ve two ListFragments maganed by a tabhost. Firt time I switch between tab all is alright. The headerView is correctly added. The second time I switch between fragment I get this execption:

10-05 15:15:01.585: ERROR/AndroidRuntime(23263): java.lang.IllegalStateException: Cannot add header view to list -- setAdapter has already been called. 
10-05 15:15:01.585: ERROR/AndroidRuntime(23263):     at android.widget.ListView.addHeaderView(ListView.java:261) 
10-05 15:15:01.585: ERROR/AndroidRuntime(23263):     at android.widget.ListView.addHeaderView(ListView.java:284) 
10-05 15:15:01.585: ERROR/AndroidRuntime(23263):     at it.chiesacattolica.archive.ArchiveFragment.onActivityCreated(ArchiveFragment.java:199) 
10-05 15:15:01.585: ERROR/AndroidRuntime(23263):     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:858) 
10-05 15:15:01.585: ERROR/AndroidRuntime(23263):     at android.support.v4.app.FragmentManagerImpl.attachFragment(FragmentManager.java:1183)

and the app crashes. The code I use to add the header view follows:

@Override
public void onActivityCreated(Bundle arg0) {
    super.onActivityCreated(arg0);      
    getListView().setOnScrollListener(this);
    getListView().addHeaderView(searchBox);
    setListAdapter(mAdapter);
}

what’s wrong ? thanks in advance

  • 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-05-26T01:32:11+00:00Added an answer on May 26, 2026 at 1:32 am

    After a fleeting look at the android developers references, I’m guessing you can’t do another call to addHeaderView after you’ve set the adapter.
    If there is such a thing, you can unload the adapter, add the new HeaderView and re-load the adapter. If not, all HeaderViews should be added before calling the setAdapter method.

    see ListView.addHeaderView

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

Sidebar

Related Questions

Two quotes: All of the remaining messages in the protocol take the form of
Two simple tables: T1 ContactId, Name, Department T2 AddressId OwnerId Address Added What I
Two questions: If I remove all the data inside a collection (db.mycollection.remove({})) will the
Two R questions: What is the difference between the type (returned by typeof )
I have two ListFragments next to each other. The left one shows categories to
I have an application which has two Tabs. Both of these are ListFragments. The
Two RAID volumes, VMware kernel/console running on a RAID1, vmdks live on a RAID5.
Two years ago, we shipped a multi-gigabyte Windows application, with lots of video files.
Two questions: Can someone point me to unbiased data that compares .NET performance to
Two snippets of MySQL: SELECT * FROM annoyingly_long_left_hand_table LEFT JOIN annoyingly_long_right_hand_table ON annoyingly_long_left_hand_table.id =

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.