fragments in viewpager, no view found error

前端 未结 8 1222
面向向阳花
面向向阳花 2020-12-19 09:23

I have an activity holding a fragment, in this fragment there is a button , when it is clicked, a dialog is popped out.

In this dialog, there is a Viewpager, which

8条回答
  •  臣服心动
    2020-12-19 10:20

    The error sounds like it's looking for the id pager in the xml file for DummyFragment (fragment_dummy_layout.xml). I wonder if this is due to calling View v = inflater.inflate(R.layout.fragment_dummy_layout, container, false); in the same file as setContentView(R.layout.dialog);. Have you tried separating DummyFragment into it's own file?

    You could also try

    View v = getActivity().getLayoutInflater().inflate(R.layout.fragment_dummy_layout, 
            container, false);
    

提交回复
热议问题