当前位置: 代码迷 >> Android >> tabHost.newTabSpec()出现空指针异常
  详细解决方案

tabHost.newTabSpec()出现空指针异常

热度:164   发布时间:2016-05-01 17:42:50.0
tabHost.newTabSpec()出现空指针错误
tabHost.setCurrentTab(0);
tabHost.addTab(tabHost.newTabSpec(TAB_LOCAL_MUSIC)
.setIndicator(TAB_LOCAL_MUSIC).
setContent(new Intent(MainActivity.this,LocalMusicActivity.class)));
tabHost.addTab(tabHost.newTabSpec(TAB_RANDOM_LISTEN)
.setIndicator(TAB_RANDOM_LISTEN)
.setContent(new Intent(MainActivity.this,RandomListenActivity.class)));
tabHost.addTab(tabHost.newTabSpec(TAB_SEARCH_SONGS)
.setIndicator(TAB_SEARCH_SONGS)
.setContent(new Intent(MainActivity.this,SearchSongsActivity.class)));


------解决方案--------------------
类似问题及解决办法:
http://stackoverflow.com/questions/8538437/your-content-must-have-a-tabhost-whose-id-attribute-is-android-r-id-tabhost
http://morry.iteye.com/blog/744598
------解决方案--------------------
看这里:
http://blog.csdn.net/aminfo/article/details/7795450