include - Hide included layout in android -


i have develop android application.

i have created 1 layout file uses layout file using include tag.

  <include     android:id="@+id/footer"     android:layout_width="match_parent"     android:layout_height="60dp"     android:layout_alignparentbottom="true"     layout="@layout/footer_tabs" />   <include     android:id="@+id/footer1"     android:layout_width="match_parent"     android:layout_height="60dp"     android:layout_alignparentbottom="true"     layout="@layout/footertabs" /> 

i show included layout when response null, otherwise hide layout , show other. here have far:

footertabs = (relativelayout) findviewbyid(r.id.footertab); footer_tabs = (relativelayout) findviewbyid(r.id.footer_tab);  if (constants.response==null) {     footertabs.setvisibility(view.visible);     footer_tabs.setvisibility(view.gone); } else {     footertabs.setvisibility(view.gone);     footer_tabs.setvisibility(view.visible); } 

but i'm getting following error:

07-15 17:19:09.893: e/androidruntime(15143): caused by: java.lang.nullpointerexception 07-15 17:19:09.893: e/androidruntime(15143):    @ com.example.androidbestinuk.homepage.oncreate(homepage.java:56) 

please me debug error.

you should change

footertabs = (relativelayout) findviewbyid(r.id.footertab); footer_tabs = (relativelayout) findviewbyid(r.id.footer_tab); 

with

footertabs = (relativelayout) findviewbyid(r.id.footer); footer_tabs = (relativelayout) findviewbyid(r.id.footer1); 

Comments