Replacing fragments within viewpager

前端 未结 2 846
再見小時候
再見小時候 2021-01-27 11:27

I am currently having an issue with replacing a certain fragment within ViewPager with another. The fragment id like to replace is my \"Departments\" which has an Imagebutton id

2条回答
  •  既然无缘
    2021-01-27 11:36

    I'm assuming you want the Engineering fragment to be on a completely new page, because you aren't using it in your ViewPagerAdapter. If that's the case, create a new Activity, with your Engineering fragment in the layout, and launch the Activity from the engineeringButton click.

    The problem is you are trying to shove your Engineering fragment into the View hierarchy of R.layout.activity_departments, and there is (hopefully) no ViewPager in there, hence the error.

提交回复
热议问题