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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:36:10+00:00 2026-06-06T02:36:10+00:00

I am getting crash reports on android.widget.ListView lv; lv.removeFooterView(v) The error is null pointer

  • 0

I am getting crash reports on

 android.widget.ListView  lv;  lv.removeFooterView(v)

The error is null pointer exception. I check that listView itself is not null. What causes this? Is it necessary to make sure the view to be removed is not null? Is that enough or do I first need to also check that the footer view actually has been added?

java.lang.NullPointerException
at android.widget.ListView.removeFooterView(ListView.java:374)

It seems to me this method should be robust enough not to crash! Why does it not just return false if it cannot remove the view?

PS. I would like to know if anyone else has seen this?

  • 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-06T02:36:11+00:00Added an answer on June 6, 2026 at 2:36 am

    Unfortunately you don’t mention what Android version the error reports are coming from. However, looking at the source code, Android 2.1-update1 seems like a good candidate.

    I’ll just copy in the whole method to make things clear:

    public boolean removeFooterView(View v) {
        if (mFooterViewInfos.size() > 0) {
            boolean result = false;
            if (((HeaderViewListAdapter) mAdapter).removeFooter(v)) { // <- line 274
                mDataSetObserver.onChanged();
                result = true;
            }
            removeFixedViewInfo(v, mFooterViewInfos);
            return result;
        }
        return false;
    }
    

    Now compare above removeFooterView(...) method with the implementation of a more recent platform:

    public boolean removeFooterView(View v) {
        if (mFooterViewInfos.size() > 0) {
            boolean result = false;
            if (mAdapter != null && ((HeaderViewListAdapter) mAdapter).removeFooter(v)) {
                if (mDataSetObserver != null) {
                    mDataSetObserver.onChanged();
                }
                result = true;
            }
            removeFixedViewInfo(v, mFooterViewInfos);
            return result;
        }
        return false;
    }
    

    As you can see, the’ve added in a couple of extra checks for certain members not being null. That would suggest that the first method will indeed fail on line 274 if mAdapter == null, whereas that wouldn’t cause a crash with the newer implementation.

    To work around it, all you probably need to do is add something like lv.getAdapter() != null before trying to remove the footer view.

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

Sidebar

Related Questions

I'm getting reports from users that my app crash upon launch. So I got
I'm getting the following message in my users' crash logs: Dyld Error Message: Symbol
Getting a rendering error for this form: 'NoneType' object has no attribute 'widget' http://dpaste.com/88585/
I am getting a crash report back that says OutOfMemoryError in my call to
I'm getting a crash that, to me, seems as though it is a bug
I am getting crash reports from sporadic SQLiteException s in my application. I am
I user android/proguard/ACRA. Can anyone tell me please why the crash reports I am
XCode 3.1.2 using built-in OCTest unit testing. I'm getting a crash when unit tests
Getting the above error in following code. How to rectify it. Thanks. Please look
Getting this error: 2009-09-03 12:44:02.307 xcodebuild[307:10b] warning: compiler 'com.apple.compilers.llvm.clang.1_0.analyzer' is based on missing compiler

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.