Problem with Android null pointer:

Source: Internet
Author: User

============ Problem Description ============


Android null pointer for two days, still did not find the error, know where the null pointer but do not know how to change

You got a spare, buddy, help qq517835354.


Error code:


Gastronomylist.class:
/** *  Everything for testing  */private ExpandTabView expandTabView;private ArrayList<View>  mViewArray = new ArrayList<View> ();p rivate viewmiddle viewmiddle;private  void init () { tv_menu1 =  (TextView) Findviewbyid (r.id.tv_menu1);tv_menu2 =  ( TextView) Findviewbyid (R.ID.TV_MENU2) tv_menu2.setvisibility (view.gone);tv_menu3 =  (TextView) Findviewbyid (R.ID.TV_MENU3); Tv_menu1.settext (Getintent (). Getstringextra ("menu"));//Get pass-through classification idcategoryid =  getintent (). Getstringextra ("id"), Tv_menu1.setonclicklistener (This),//tv_menu2.setonclicklistener (this); Tv_menu3.setonclicklistener (this); View view = layoutinflater.from (context). Inflate (r.layout.bottom_bar, null); lv_list =   (ListView) Findviewbyid (R.id.lv_list_ms); list_list = new arraylist

error message:

============ Solution 1============


You check the activity_gastronomy_list.xml. There is no corresponding control with ID expandtab_view.

============ Solution 2============


The 2 floor is good, because Android's current mechanism is to return NULL when Findviewbyid cannot find the corresponding control, instead of throwing an exception, and null can be coerced into any type.

Therefore, you need to check that the layout file has a corresponding ID in the control

Problem with Android null pointer:

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.