“No view found for id for fragment” error of Nested Viewpager
Fevzi Ömür Tekin
Posted on September 13, 2019
I'm getting an error in the title. Application I also have a mixed structure and use a few nested structures.
There is a structure like " CategoryFragment -> ViewPager -> RecyclerView inside CategoryDetailsFragment -> ViewPager-> HeadlinePagerFragment"
when changed to CategoryFragment then return to back will be this error.
- CategoryFragment
val
…
I'm getting an error in the title. Application I also have a mixed structure and use a few nested structures.
There is a structure like " CategoryFragment -> ViewPager -> RecyclerView inside CategoryDetailsFragment -> ViewPager-> HeadlinePagerFragment"
when changed to CategoryFragment then return to back will be this error.
- CategoryFragment
val adapter = CategoriesPagerAdapter(activity?.supportFragmentManager!!,list as List<MutableMap<String,String>>)
vp_categories_pager.adapter = adapter
tl_categories.setupWithViewPager(vp_categories_pager)
- CategoryDetailsFragment This class use recyclerview and usage inside of childview viewpager.
rv_category_details.adapter = ContentAdapter(
context!!,this@CategoryDetailsFragment(usage as fragment),
this@CategoryDetailsFragment)
-> Adapter
vp_headline.adapter =HeadlineAdapter(
fragment?.childFragmentManager!!,
items, itemClickListener)
tl_headline_indicator.setupWithViewPager(vp_headline)
- HeadlineAdapter
class HeadlineAdapter(
fragment: FragmentManager,
var list:MutableList<MutableMap<*,*>>,
val itemclickListener:ContentAdapter.Itemclicklistener)
:FragmentPagerAdapter(fragment){
override fun getItem(position: Int): Fragment =
HeadlinePagerFragment(PutData(mutableMapOf(
'm' to list[position],
'l' to itemclickListener
)))
override fun getCount(): Int = list.size
override fun getItemPosition(`object`: Any): Int {
return PagerAdapter.POSITION_NONE
}
}
Return this error
No view found for id 0x7f0901de (com.bursadabugun.android:id/vp_headline) for fragment HeadlinePagerFragment{17872d5 (85c9643d-c164-417e-a428-7105105970a1) id=0x7f0901de android:switcher:2131296734:0}
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:875)
at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1238)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1303)
at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManagerImpl.java:2656)
at androidx.fragment.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManagerImpl.java:2610)
at androidx.fragment.app.Fragment.performActivityCreated(Fragment.java:2619)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:904)
at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1238)
at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:434)
at androidx.fragment.app.FragmentManagerImpl.executeOps(FragmentManagerImpl.java:2076)
at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1866)
at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:1821)
at androidx.fragment.app.FragmentManagerImpl.execSingleAction(FragmentManagerImpl.java:1696)
at androidx.fragment.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:299)
at androidx.fragment.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:230)
at androidx.viewpager.widget.ViewPager.populate(ViewPager.java:1244)
at androidx.viewpager.widget.ViewPager.populate(ViewPager.java:1092)
at androidx.viewpager.widget.ViewPager.onMeasure(ViewPager.java:1622)
at android.view.View.measure(View.java:22094)
at androidx.constraintlayout.widget.ConstraintLayout.internalMeasureChildren(ConstraintLayout.java:1227)
at androidx.constraintlayout.widget.ConstraintLayout.onMeasure(ConstraintLayout.java:1572)
at android.view.View.measure(View.java:22094)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6613)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at android.view.View.measure(View.java:22094)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6613)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at android.view.View.measure(View.java:22094)
at androidx.constraintlayout.widget.ConstraintLayout.internalMeasureChildren(ConstraintLayout.java:1227)
at androidx.constraintlayout.widget.ConstraintLayout.onMeasure(ConstraintLayout.java:1572)
at android.view.View.measure(View.java:22094)
at androidx.drawerlayout.widget.DrawerLayout.onMeasure(DrawerLayout.java:1119)
at android.view.View.measure(View.java:22094)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6613)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at androidx.appcompat.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:143)
at android.view.View.measure(View.java:22094)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6613)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1514)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:806)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:685)
at android.view.View.measure(View.java:22094)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6613)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at android.view.View.measure(View.java:22094)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6613)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1514)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:806)
E/AndroidRuntime: at android.widget.LinearLayout.onMeasure(LinearLayout.java:685)
at android.view.View.measure(View.java:22094)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6613)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at com.android.internal.policy.DecorView.onMeasure(DecorView.java:724)
at android.view.View.measure(View.java:22094)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2483)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1549)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1806)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1432)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6826)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911)
at android.view.Choreographer.doCallbacks(Choreographer.java:723)
at android.view.Choreographer.doFrame(Choreographer.java:658)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6543)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:440)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:810)
Posted on September 13, 2019
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.