TabPageIndicator+ViewPager(java.lang.IllegalStateException: ViewPager has not been bound.)

当在布局定义了一个TabPageIndicator和一个ViewPager,如果这时候直接显示布局,会报以下错误

java.lang.IllegalStateException: ViewPager has not been bound.

这是因为没有绑定ViewPager到TabPageIndicator,需要添加代码:

tabPageIndicator.setViewPager(viewPager);

你可能感兴趣的:(TabPageIndicator+ViewPager(java.lang.IllegalStateException: ViewPager has not been bound.))