Android Listview Addheaderview setadapter when inexplicable nullpointerexception solved

Source: Internet
Author: User

Solve Android Listview Addheaderview Setadapter when inexplicable nullpointerexception


Bug when changing the code



Bug 1:


E/androidruntime (15920): java.lang.RuntimeException:Unable to start activity componentinfo{}: Android.view.InflateException:Binary XML file line #35: Error inflating class fragment


Solution Ideas

Ran into Binary XML file line #35

1 go to check the relevant fragment XML configuration is correct

2 Check if import package is import android.app.v4.Fragment



Bug 2:

ListView inexplicably NullPointerException


E/androidruntime (18769): caused by:java.lang.NullPointerException


At Android.widget.ListView.clearRecycledState

At android.widget.ListView.resetList


Solution Ideas:


Check to see if the header or footer is loaded as follows:


View Header = Getlayoutinflater (). Inflate (R.layout.header, NULL); View footer = Getlayoutinflater (). Inflate (r.layout.footer, NULL);


Reference:


http://blog.sina.com.cn/s/blog_6e5195850101492t.html

┏┓┏┓//┏┛┻━━━┛┻┓//┃┃//┃━┃//┃┳┛┗┳┃//┃┃//┃┻┃//┃┃//┗━┓┏━┛//  ┃┃   god beast bless  ┃┃   Code no bug!  ┃┗━━━┓//  ┃┣┓//  ┃┏┛//  ┗┓┓┏━┳┓┏┛//    ┃┫┫┃┫┫//    ┗┻┛┗┻┛

Daily Diligence



Android Listview Addheaderview setadapter when inexplicable nullpointerexception solved

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.