============ 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 controlProblem with Android null pointer: