Android: The findviewbyid is used to obtain that the Interface Element Object is null. a null pointer exception is prompted during running.

Source: Internet
Author: User

Ah, I am leaving. I encountered this problem during development today. Everything is okay. How can I get a null pointer exception? The logic is absolutely no problem. I use simplecursoradapter. First, I cannot obtain the data of holder given by newview in BindView. debug found that the value assigned to the holder object in newview is null, I found that findviewbyid () is null. There is no reason for this. I found the information online and cried.


Generally, there are three situations that cause this result. Let's briefly describe:

First, the layout file is not loaded, that is, findviewbyid () before the layout is set. This is definitely not available. This is the problem of chicken and eggs. Needless to say;

Second, the view should be a tree-like organization. It cannot be found from the current contentview. You must set contentview to include the contentview to be found;

Third, it is caused by eclipse. Once the project is clean (Project menu-> clean sub-menu), it will be OK.


Second, I fell into the third situation, and I had to struggle. It's okay to clean it. Are you two, bro ?!

Related Article

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.