android.content.res.Resources$NotFoundException: Unable to find resource ID #0xffffffff

以下是使用viewpager时出现的错误日志:

android.content.res.Resources$NotFoundException: Unable to find resource ID #0xffffffff

at android.content.res.Resources.getResourceName(Resources.java:1679)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:947)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1138)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:740)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1501)
at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:490)
at android.support.v4.app.FragmentStatePagerAdapter.finishUpdate(FragmentStatePagerAdapter.java:163)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1105)
at android.support.v4.view.ViewPager.populate(ViewPager.java:951)
at android.support.v4.view.ViewPager.setAdapter(ViewPager.java:446)


原因是:

        当viewpager是动态添加时(new Viewpager),不设置id就会报以上错误,这是google的api问题。

解决:

       viewpager.setId();

你可能感兴趣的:(android,viewpager)