Attempt to invoke virtual method 'void android.support.v4.view.ViewPager.setAdapter(android.support.v4.view.PagerAdapter)' on a null object reference

痴心易碎 提交于 2019-11-30 18:06:52

You have your view pager in activity_main.xml while your layout for activity is setContentView(R.layout.activity_main_appbar). You do not have view pager in activity_main_appbar.xml.

findViewById looks for a view in the current view hierarchy. I guess it should be setContentView(R.layout.activity_main); but do check what views you have in included layout app_bar.xml

It May be you pass an wrong id of viewPager.Please Check your id from XML File

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!